Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Using env:AEM_PROXY_HOST in the code

Avatar

Level 5

We're using javax.mail in our code to send emails and we're also having a custom osgi config to store host, port, etc...

 

com.company.config.CompanyEmailService.cfg.json

{
"mail.smtp.host":"$[env:AEM_PROXY_HOST;default=proxy.tunnel]",
"mail.smtp.port":"30002",

.

.

}

 

How we can "make" aem to transform from this $[env:AEM_PROXY_HOST;default=proxy.tunnel] to something that we defined under advanced networking configuration.

{
            "name""smtp.gmail.com",
            "portDest"465,
            "portOrig"30002            
}

When mail.smtp.host is read from our custom config it stays unchanged and mail can't be send because it's using this string as is as a server name,  $[env:AEM_PROXY_HOST;default=proxy.tunnel],

 

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 5

We managed to resolved the issue by using System.getenv("AEM_PROXY_HOST")  in our code.

View solution in original post

6 Replies

Avatar

Community Advisor

Hi @nbg62 

 

SMTP configuration can be done as below example

 

{
"debug.email": false,
"smtp.user": "$[secret:smtpuser]",
"smtp.password": "$[secret:smtppassword]",
"smtp.port": 465,
"smtp.ssl": true,
"smtp.starttls": true,
"smtp.host": "in.mailjet.com",
"from.address": "XXXXXXXXXX"
}

And also you can refer to below URL as well

https://experienceleague.adobe.com/docs/experience-manager-learn/cloud-service/networking/examples/e...

 

 

Avatar

Level 5

I understand that on Aem Cloud, port forwarding is required and $[env:AEM_PROXY_HOST;default=proxy.tunnel] needs to be used as stated in the URL that you shared ?

 

 

 

Avatar

Community Advisor

@nbg62 It is not necessarly needed to every time use $[env:AEM_PROXY_HOST;default=proxy.tunnel] syntax. Still the old way of implementation on-prem works. 

 

This will be used only when we have 2 environment with same runmode. for ex: Dev and QA

 

In cloud dev and qa both are considered as dev environments so we can not have 2 different configurations. So it is recommanded to use $[env:AEM_PROXY_HOST;default=proxy.tunnel] way of implementation 

Avatar

Level 5

Thanks  Jagadeesh,

 

I don't follow you on this, "This will be used only when we have 2 environment with same runmode. for ex: Dev and QA", I can distinguish every config/env, like config.author.dev, config.author.stage, etc...

 

Can you tell how's $[env:AEM_PROXY_HOST;default=proxy.tunnel]  mapped internally ?

 

Avatar

Correct answer by
Level 5

We managed to resolved the issue by using System.getenv("AEM_PROXY_HOST")  in our code.