Custom SMTP set up for AEM as a Cloud Service | Community
Skip to main content
aanchal-sikka
Community Advisor
Community Advisor
June 12, 2023

Custom SMTP set up for AEM as a Cloud Service

  • June 12, 2023
  • 2 replies
  • 2470 views

Hello

 

We need to set up multiple SMTP configurations. The OOTB "Day CQ Mail Service" supports only one config. So, to achieve multiple SMTP configurations, we are trying to create a custom implementation to send emails

 

The code is working on local, but we are receiving Connection time out on cloud. We are guessing it is due to proxy.tunnel used in Day CQ Mail Service.

 

How to can we get through the proxy tunnel using custom code for sending emails?

 

Reference about proxy tunnel used in Day CQ Mail Service is available athttps://experienceleague.adobe.com/docs/experience-manager-learn/cloud-service/networking/examples/email-service.html?lang=en.

 

details of working local setup:

- Gmail SMTP set up configured as per https://techrevel.blog/2023/06/12/utilizing-gmail-smtp-for-cost-free-email-transmission-from-aem/

- Custom send email code working on local :

 

public void send() { //Get properties object Properties props = new Properties(); props.put("mail.smtp.host", smtpConfig.smtpHost()); props.put("mail.smtp.socketFactory.port", smtpConfig.smtpPort()); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.port", smtpConfig.smtpPort()); //get Session Session session = Session.getInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(smtpConfig.fromAddress(), smtpConfig.smtpPassword()); } }); //compose message try { MimeMessage message = new MimeMessage(session); message.addRecipient(Message.RecipientType.TO, new InternetAddress("madhankumar.sugumar@brillio.com")); message.setSubject("Subject !!"); message.setText("Message !!!"); //send message Transport.send(message); LOGGER.info("message sent successfully"); } catch (MessagingException e) { throw new RuntimeException(e); } }

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

aanchal-sikka
Community Advisor
Community Advisor
July 10, 2023

As per Adobe support, multiple SMTP set up is not supported on the AEM as a Cloud Service.

Aanchal Sikka