AEM cannot send outbound SMTP emails due to mail service or Advanced Networking misconfiguration

AEM environments can fail to send outbound email, with logs showing SMTP connection errors such as EmailException or MailConnectException, and email that works locally but fails on AEM as a Cloud Service. To fix the issue, confirm your environment type, correct the mail service and Advanced Networking configuration, and validate SMTP connectivity in the logs.

Description description

Environment

  • Adobe Experience Manager as a Cloud Service
  • AEM Managed Services
  • Adobe Experience Manager 6.5 (on-premise)
  • AEM Forms

Issue/Symptoms

  • Logs show an SMTP send failure such as EmailException: Sending the email to the following server failed.
  • Publish logs show MailConnectException: Could not connect to the host, port.
  • Email works on localhost but fails on AEM as a Cloud Service (dev, stage, or publish).
  • The AEM Forms email endpoint processes slower than expected or not at the expected interval.

Root cause

Outbound SMTP failures occur due to one or more of the following: missing Advanced Networking port-forwarding rules (required for all external SMTP connections in AEMaaCS), misconfigured OSGi mail service values (for example, using the direct SMTP port instead of the mapped portOrig), incorrect credentials or a missing configuration-as-code deployment in AEMaaCS, or a misunderstanding of the scheduler and interval behavior in AEM Forms email endpoints.

Steps to reproduce

  • Determine whether the environment is AEM as a Cloud Service or AEM 6.5 on-premise, since the configuration path differs.
  • Review the error logs for EmailException or MailConnectException entries.
  • Check the mail service configuration source: the com.day.cq.mailer.DefaultMailService.cfg.json file (AEMaaCS) or the Day CQ Mail Service in the Web Console (AEM 6.5).
  • For AEMaaCS, confirm Advanced Networking port forwarding maps your portOrig (for example, 30465 or 30587) to the destination port (465 or 587).

Resolution resolution

To fix the issue:

  1. Identify the environment type - AEM as a Cloud Service or AEM 6.5 on-premise - because the mail configuration differs between them.
  2. Review the error logs. For AEMaaCS, open Cloud Manager > Environments > Logs; for AEM 6.5, check error.log. Search for EmailException, MailConnectException, and proxy.tunnel. If no relevant logs appear, set smtp.debug=true in the OSGi configuration.
  3. Locate the mail service configuration. For AEMaaCS, review com.day.cq.mailer.DefaultMailService.cfg.json in your configuration-as-code; for on-premise, open the Web Console at /system/console/configMgr and select Day CQ Mail Service. Confirm the SMTP host, port, username, password, and SSL values are populated. If the configuration is missing in AEMaaCS, deploy it as code.
  4. For AEM as a Cloud Service only, validate Advanced Networking. Confirm that port forwarding maps your portOrig (for example, 30465 or 30587) to the destination port (465 or 587). In the OSGi config, smtp.host uses the proxy host variable (AEM_PROXY_HOST, default proxy.tunnel) and smtp.port uses the portOrig value. Update the portForwards configuration in Cloud Manager if needed.
  5. For AEM as a Cloud Service only, configure the SMTP port and SSL correctly. For SSL-enabled SMTP (destination port 465), set smtp.port to your mapped 30xxx port and smtp.ssl=true (for example, portOrig 30465 maps to smtp.port 30465 with smtp.ssl=true).
  6. For AEM as a Cloud Service only, verify environment variables. In Cloud Manager > Environment > Configuration, confirm that variables such as EMAIL_USERNAME, EMAIL_PASSWORD, and AEM_PROXY_HOST exist and are spelled correctly, then redeploy after any change.
  7. For AEM 6.5 on-premise only, configure the Day CQ Mail Service. In /system/console/configMgr, select Day CQ Mail Service and set the SMTP host, a port of 25 or higher, the user and password, and a non-blank from address. Restart AEM if the changes do not take effect.
  8. For AEM Forms only, validate the email endpoint. Review the repeat interval, batch size, and cron expression so the scheduler processes batches at the expected timing, and re-tune the settings if needed.
  9. Test email delivery by triggering the feature that sends email (a form submission, servlet call, or workflow). Confirm the email is received and that the logs show a successful SMTP handshake with no EmailException or MailConnectException.
  10. If email still fails, contact Adobe Support with the error.log snippets showing the exception, your Day CQ Mail Service configuration file (the AEMaaCS cfg.json), your SMTP host and port mapping details, and confirmation of whether Advanced Networking is enabled.
recommendation-more-help
experience-cloud-kcs-help-kbarticles