I found below document which talks about email configuration. However, I would like to know if we have any other documentation that can refer along with this.
I would like to test with gmail account. Any help is really appreciated!
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @lmalyala
You need to create one OSGi configuration with name "com.day.cq.mailer.DefaultMailService.xml" and add the below config into it.
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
smtp.host="smtp.gmail.com"
smtp.port="465"
smtp.user="demo@gmail.com"
smtp.password="Demo@123"
from.address="no-reply@gmail.com"
smtp.ssl="{Boolean}true"
smtp.starttls="{Boolean}true"
debug.email="{Boolean}true"/>
User name and password should be of the gmail account.
Please ensure to turn off the less secure app in gmail so it will not stop sending the email. Also note that you can send upto 500 emails using gmail account.
https://support.google.com/accounts/answer/6010255?hl=en
Thanks!
Use ACS email service. Here is the documentation:
https://adobe-consulting-services.github.io/acs-aem-commons/features/e-mail/email-api/index.html
Hi @lmalyala
You need to create one OSGi configuration with name "com.day.cq.mailer.DefaultMailService.xml" and add the below config into it.
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
smtp.host="smtp.gmail.com"
smtp.port="465"
smtp.user="demo@gmail.com"
smtp.password="Demo@123"
from.address="no-reply@gmail.com"
smtp.ssl="{Boolean}true"
smtp.starttls="{Boolean}true"
debug.email="{Boolean}true"/>
User name and password should be of the gmail account.
Please ensure to turn off the less secure app in gmail so it will not stop sending the email. Also note that you can send upto 500 emails using gmail account.
https://support.google.com/accounts/answer/6010255?hl=en
Thanks!
Hey! This solution works perfectly in local instance. However, it is throwing below error in AEMaaCS instance. Looks like by default, ports will be disabled in AEMaaCS and needs to be enabled as per https://experienceleague.adobe.com/docs/experience-manager-learn/cloud-service/networking/examples/e...
Error in AEMaacs instance:
Caused by: org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:465
Caused by: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 465; timeout 60000
Caused by: java.net.SocketTimeoutException: connect timed out
Could you please help me with steps to resolve this issue in AEMaacs instance?
Hi @lmalyala
You need to configure the OSGi details as mentioned below:
{
"smtp.host": "$[env:AEM_PROXY_HOST;default=proxy.tunnel]",
"smtp.port": "30002",
"smtp.user": "$[env:EMAIL_USERNAME;default=apikey]",
"smtp.password": "$[secret:EMAIL_PASSWORD]",
"from.address": "no-reply@gmail.com",
"smtp.ssl": true,
"smtp.starttls": false,
"smtp.requiretls": false,
"debug.email": false,
"oauth.flow": false
}
Then you need to enable the ENV Variables using the Cloud Manager:
Once the Env variables are configured, Enable Environment Advanced Networking Configuration using Cloud Manager API and it should resolve the issue!
Thanks!
Hi @lmalyala
Just to let you know I have implemented this on AEM as Cloud and it works perfectly fine!
You can try with https://mailtrap.io/ SMTP as well if you do not want to go with Gmail or having issue with Gmail.
Thanks!
@Asutosh_Jena_ Thanks for checking again. I'll try these steps now and update you on how it goes. Just one quick thing: Where can I configure those environment variables? Can you help me navigate to the screen. Is it via admin console?
Never mind! I figured it out
Sounds good!
Hey @Asutosh_Jena_ - I was successfully able to follow and setup the steps shared by you. However, I still see below errors. Any idea on what am I missing?
Caused by: org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:30002
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1469) [org.apache.commons.email:1.5.0]
at org.apache.commons.mail.Email.send(Email.java:1496) [org.apache.commons.email:1.5.0]
at com.day.cq.mailer.impl.DefaultMailService.send(DefaultMailService.java:331) [com.day.cq.cq-mailer:5.4.20]
Caused by: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 30002; timeout 60000
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2209) [com.sun.mail.javax.mail:1.6.2]
Caused by: java.net.SocketTimeoutException: connect timed out
Hi @lmalyala
Did you enable the AdvancedNetworkingConfiguration? You can enable it by making the Cloud Manager API call with Adobe I/O.
Before that you need to create one network infrastructure. Follow the steps mentioned here:
https://www.adobe.io/experience-cloud/cloud-manager/reference/api/#tag/Network-infrastructure
Here you need to pass the PORT Forward rules and it will resolve the issue.
Let me know if you have any questions and I can connect if required.
Thanks!
Hi @Asutosh_Jena_ - Yes, I have hit both APIs (Create network infrastructure API followed by Enable environment network environment API). While hitting enable environment network environment API, I have sent below JSON in the request body and I was successfully able to fetch the response which is similar to sample response structure mentioned here (https://www.adobe.io/experience-cloud/cloud-manager/reference/api/#operation/enableEnvironmentAdvanc...). Just wondering what else am I missing.
When I hit https://www.adobe.io/experience-cloud/cloud-manager/reference/api/#operation/getEnvironmentAdvancedN... I can see the port that I have set is enabled
Please review the configuration in OSGi console - "Day CQ Mail Service" as below:
Please refer this article - https://www.albinsblog.com/2019/11/SMTPSendFailedException-Must-issue-a-STARTTLS-adobe-experience-ma...
Regards,
Raja