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
EmailExceptionorMailConnectExceptionentries. - Check the mail service configuration source: the
com.day.cq.mailer.DefaultMailService.cfg.jsonfile (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:
- Identify the environment type - AEM as a Cloud Service or AEM 6.5 on-premise - because the mail configuration differs between them.
- Review the error logs. For AEMaaCS, open Cloud Manager
>Environments>Logs; for AEM 6.5, checkerror.log. Search forEmailException,MailConnectException, andproxy.tunnel. If no relevant logs appear, setsmtp.debug=truein the OSGi configuration. - Locate the mail service configuration. For AEMaaCS, review
com.day.cq.mailer.DefaultMailService.cfg.jsonin your configuration-as-code; for on-premise, open the Web Console at/system/console/configMgrand 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. - 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.hostuses the proxy host variable (AEM_PROXY_HOST, defaultproxy.tunnel) andsmtp.portuses theportOrigvalue. Update theportForwardsconfiguration in Cloud Manager if needed. - For AEM as a Cloud Service only, configure the SMTP port and SSL correctly. For SSL-enabled SMTP (destination port 465), set
smtp.portto your mapped 30xxx port andsmtp.ssl=true(for example,portOrig30465 maps tosmtp.port30465 withsmtp.ssl=true). - For AEM as a Cloud Service only, verify environment variables. In Cloud Manager
>Environment>Configuration, confirm that variables such asEMAIL_USERNAME,EMAIL_PASSWORD, andAEM_PROXY_HOSTexist and are spelled correctly, then redeploy after any change. - 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. - 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.
- 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
EmailExceptionorMailConnectException. - If email still fails, contact Adobe Support with the
error.logsnippets showing the exception, your Day CQ Mail Service configuration file (the AEMaaCScfg.json), your SMTP host and port mapping details, and confirmation of whether Advanced Networking is enabled.