AEM as a Cloud Service: SMTP email delivery fails
SMTP email delivery can fail in Adobe Experience Manager as a Cloud Service (AEMaaCS) when the mail service is configured to connect directly to an external SMTP host on a non-default port, or when the required Advanced Networking port-forwarding configuration is missing or incorrect. Resolve the issue by configuring Advanced Networking for the SMTP destination and updating the Day CQ Mail Service to use the proxy host and mapped proxy port.
Description description
Environment
Adobe Experience Manager as a Cloud Service (all versions)
Issue/Symptoms
When attempting to send emails via SMTP, such as through rollout jobs or asynchronous tasks, email delivery fails. The following errors are observed in the logs:
Caused by: org.apache.commons.mail.EmailException: Sending the email to the following server failed : your-smtp-host:465
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1298) [ org.apache.commons.commons-email:1.6.0]
...
Caused by: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: your-smtp-host, 465; timeout 60000
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2209) [ com.sun.mail.javax.mail:1.6.2]
...
Caused by: java.net.SocketTimeoutException: Connect timed out
at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:546)
- Email sending fails for jobs or processes that use SMTP.
- The logs show connection timeouts when the mail service attempts to connect to the SMTP server on port 465.
- The Day CQ Mail Service configuration should be reviewed to confirm that AEM as a Cloud Service is using the required proxy host and mapped proxy port rather than connecting directly to the external SMTP host and port.
Root Cause
In AEM as a Cloud Service, SMTP delivery can fail when a non-default SMTP port such as 465 is used without the required Advanced Networking port-forwarding configuration, or when the mail service is configured to use the external SMTP host and destination port directly instead of the mapped proxy host and port.
Resolution resolution
Try the following steps to solve the issue:
-
Ensure Advanced Networking is enabled for the target AEM as a Cloud Service program and environment, and that you have the required permissions to update networking and configuration.
-
In Cloud Manager, open the relevant program and environment. Go to Advanced Networking and configure a flexible port egress rule for your SMTP service. Use a rule similar to the following example, replacing the hostname and ports with the values required by your SMTP provider. Use a suitable
portOrigvalue in the documented range for your environment. Save and apply the configuration to the environment.code language-json { "nonProxyHosts": [ ] , "portForwards": [ { "name": "smtp.example.com", "portDest": 465, "portOrig": 30465 } ] } -
Configure the mail service to use the proxy host and the mapped proxy port rather than connecting directly to the external SMTP host and port. Use the following values:
smtp.host:$[ env:AEM_PROXY_HOST;default=proxy.tunnel]smtp.port:<mapped-port>(or theportOrigvalue configured above)smtp.user: a secret-backed value for your SMTP usernamesmtp.password: a secret-backed value for your SMTP passwordfrom.address: a valid sender address, for exampleno-reply@example.comsmtp.ssl:truewhen the destination SMTP service uses port465
-
Provide the SMTP username and password using supported secret-backed configuration for AEM as a Cloud Service rather than storing literal credential values in code.
-
Deploy the updated configuration through your standard Cloud Manager deployment process, then test email delivery by rerunning a process that sends email and confirming that the connection succeeds.