Expand my Community achievements bar.

Adobe Summit 2025: AEM Session Recordings Are Live! Missed a session or want to revisit your favorites? Watch the latest recordings now.
SOLVED

SMTP connection time out issue in AEM as cloud.

Avatar

Level 1

Hi Everyone,

 

I am working on custom work and need to send and email for approval. We are using ootb email configs. com.day.cq.mailer.DefaultMailService.cfg.json 

{
    "smtp.host": "$[env:PROJECT_SMTP_HOST]",
    "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": false,
    "oauth.flow": false
}

We have changed the smtp.host variable name to "PROJECT_SMTP_HOST" as mentioned in adobe document that 

  • $[env:AEM_PROXY_HOST] is a reserved variable that AEM as a Cloud Service maps to the internal proxy.tunnel host.
  • Do NOT attempt to set the AEM_PROXY_HOST via Cloud Manager.

We have also enabled the port forwards and egress and whitelisting of IP. 

 

Still getting the connection timeout.

 

 

1 Accepted Solution

Avatar

Correct answer by
Employee

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
}

 

View solution in original post

4 Replies

Avatar

Employee

@deepikapatel could you share the complete Error Stack Trace?

Avatar

Community Advisor

Hi @deepikapatel ,

The SMTP connection timeout in AEM as a Cloud Service usually happens due to one or more of the following issues — and from your config and setup.

1. Correct SMTP Configuration File

You're using com.day.cq.mailer.DefaultMailService.cfg.json — that's correct.

Double-check:

{
  "smtp.host": "$[env:PROJECT_SMTP_HOST]",
  "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": false
}

Confirm:

$[env:PROJECT_SMTP_HOST] is set in Cloud Manager pipeline variables.

$[secret:EMAIL_PASSWORD] is a secret variable (under secrets, not regular env vars).

Avatar

Level 2

Hi @deepikapatel ,

 

It looks like there might be an issue with the SMTP proxy tunnel on port 30465.


Can you please check with the Adobe team to confirm:

Is the SMTP proxy tunnel to port 30465 active and correctly routed for the PROJECT_SMTP_HOST environment variable?"

 

Regards,
Lavish Vasuja

Avatar

Correct answer by
Employee

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
}