Your connection timeout is most likely related to the use of the smtp.host variable and network configuration in AEM as a Cloud Service. Here is a step-by-step guide with key pointers from internal knowledge and documentation:
1. Use AEM’s Internal Proxy Host Variable - AEMasaCloudService
You must NOT set a custom variable for the host unless you have specialized networking. The required and supported way to configure this for Cloud Service uses the internal proxy variable:
"smtp.host": "$[env:AEM_PROXY_HOST;default=proxy.tunnel]"
This is internally mapped to your chosen SMTP destination during advanced networking/port forwarding. Your custom variable PROJECT_SMTP_HOST will not be recognized by the proxy/tunnel networking AEM expects, and connection will not work.
- Source: "Configure the smtp.host OSGi parameter using the variable $[env:AEM_PROXY_HOST;default=proxy.tunnel]. This is internally mapped."
2. Port Forwarding Must Match OSGi smtp.port Field
In your config, you set "smtp.port": "30465". This value needs to match the "portOrig" you use in the Cloud Manager port forwarding configuration for your SMTP service.
Example (for SMTP over 465):
"portForwards": [
{ "name": "smtp.sendgrid.net", "portDest": 465, "portOrig": 30465 }
]
Then, "smtp.port" in OSGi is 30465, NOT 465 or any custom value.
- Source: “Set the smtp.port to match the original port that aligns with the port forwarding rule established in Cloud Manager.”
3. Advanced Networking Requirements
Just enabling port forward/egress is not enough: your Cloud Manager networking config must map the proxy port ("portOrig") to your SMTP server and port ("portDest"). This allows the service to tunnel through Adobe Cloud Service’s restricted egress layer.
- Source: “Only HTTP and HTTPS ports are open by default in AEMaaCS, which may hinder SMTP connections. Configure advanced networking to permit egress through the required SMTP ports.
4. Debug and Logs
Enable "debug.email": true in your config and check AEM logs for which hostname and port are being used at runtime. If you see "proxy.tunnel" or "AEM_PROXY_HOST" resolved to something unexpected or if you see a connection timeout to a private IP, this is a clear sign of misconfiguration in these two fields.
5. Avoid Reserved Variable Names and Inconsistent Naming
You should not use custom environment variable names (like "PROJECT_SMTP_HOST") for host mapping in Cloud Service. Adobe Cloud Service expects "AEM_PROXY_HOST" in the SMTP config to correctly route mail out.
Example of a Working OSGi Email Config:
{
"smtp.host": "$[env:AEM_PROXY_HOST;default=proxy.tunnel]",
"smtp.port": "30465",
"smtp.user": "$[env:EMAIL_USERNAME]",
"smtp.password": "$[secret:EMAIL_PASSWORD]",
"from.address": "noreply@domain.com",
"smtp.ssl": true,
"smtp.starttls": false,
"smtp.requiretls": false,
"debug.email": true,
"oauth.flow": false
}