Saturday, November 23, 2019

com.day.cq.mailer.MailingException: org.apache.commons.mail.EmailException: Sending the email to the following server failed - Adobe Experience Manager

I was getting the below exception while connecting to the email server from Adobe Experience Manager

com.day.cq.mailer.MailingException: org.apache.commons.mail.EmailException: Sending the email to the following server failed : xxxxxxxxxxxxx:25
at com.day.cq.mailer.impl.DefaultMailService.send(DefaultMailService.java:302)
at com.day.cq.mailer.impl.DefaultMailService.sendEmail(DefaultMailService.java:248)
at com.day.cq.wcm.foundation.forms.impl.MailServlet.doPost(MailServlet.java:314)
at org.apache.sling.api.servlets.SlingAllMethodsServlet.mayService(SlingAllMethodsServlet.java:146)
at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:342)
at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:374)
at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:552)
at org.apache.sling.engine.impl.filter.SlingComponentFilterChain.render(SlingComponentFilterChain.java:44)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:71)
at com.adobe.granite.rest.assets.impl.AssetContentDispositionFilter.doFilter(AssetContentDispositionFilter.java:96)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:68)
at com.day.cq.wcm.core.impl.WCMDebugFilter.doFilter(WCMDebugFilter.java:138)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:68)

Caused by: org.apache.commons.mail.EmailException: Sending the email to the following server failed : xxxxxxxxxxxxx:25
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1469)
at org.apache.commons.mail.Email.send(Email.java:1496)
at com.day.cq.mailer.impl.DefaultMailService.send(DefaultMailService.java:300)
... 133 common frames omitted
Caused by: com.sun.mail.smtp.SMTPSendFailedException: 530 #5.7.0 Must issue a STARTTLS command first

at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2108)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1609)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1117)
at javax.mail.Transport.send0(Transport.java:254)
at javax.mail.Transport.send(Transport.java:124)
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1459)
... 135 common frames omitted

The reason is the mail server connection is enabled through plain text on port 25 and the mail server is expecting to upgrade the plain text connection to secure connection with STARTTLS command to establish the email communication.

Below are the options to connect email client with email server:

Pain text: 


This is unsecured, the data is sent as clear text. This method is not recommended.

SSL/TLS: 


SSL/TLS opens an SSL/TLS connection first, then begins the SMTP transaction. This must occur on a different port than the server already running non-SSL/TLS SMTP communication; it is impossible to configure a single port to handle both plain text and encrypted connections due to the nature of the protocols.

STARTTLS: 


STARTTLS starts the SMTP transaction through non secure port and looks for support from the other end for TLS in the response to EHLO. If the client sees STARTTLS in the supported command list, then it sends STARTTLS and begins negotiation for encryption. All this can (and usually does) occur on the standard SMTP port of 25, partly for backwards compatibility, but also to allow for opportunistic encryption between endpoints that both support it but don't necessarily require it.

To fix the issue enable "SMTP use StartTLS" option through "Day CQ Mail Service" OSGI system configuration

Day CQ Mail Service

No comments:

Post a Comment