Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Custom SMTP set up for AEM as a Cloud Service


Community Advisor



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/e....


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
            LOGGER.info("message sent successfully");
        } catch (MessagingException e) {
            throw new RuntimeException(e);




Aanchal Sikka

2 Replies