Expand my Community achievements bar.

I need to send multiple mail from diferrent mail addresses in aem sites. how we can do that?

Avatar

Level 1

We need to implement multiple forms on our site, each with a different server name and "from" address, but this setup is not working as expected. We're referencing the documentation from this link:
https://joao.ws/how-to-send-custom-emails-in-aem-part-2-multiple-providers/.

but this form is not working in the environment. we a another in which we have used the default.mailSErvice that is working fine on the environment as well.
ERROR:- 
21.10.2024 09:37:12.101 [cm-p123474-e1277123-aem-author-866fd95655-qzfzr] *INFO* [122.180.144.91 [1729503300341] GET /content/projectName/de/de/kontakt/jcr:content/root/container/renewablescontainer_935070413/renewablestabs/item_1/contactform.renewablesContactForm.json HTTP/1.1] com.maxboeglsitesassets.core.servlets.RenewablesContactUsFormServlet Messaging Exception: info(); while sending email :: java.net.ConnectException: Connection timed out (Connection timed out) Couldn't connect to host, port: smtp.gmail.com, 30465; timeout -1
com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 30465; timeout -1
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2209) [com.sun.mail.javax.mail:1.6.2]
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:740) [com.sun.mail.javax.mail:1.6.2]
at javax.mail.Service.connect(Service.java:388) [com.sun.mail.javax.mail:1.6.2]
at javax.mail.Service.connect(Service.java:246) [com.sun.mail.javax.mail:1.6.2]
at javax.mail.Service.connect(Service.java:195) [com.sun.mail.javax.mail:1.6.2]
at javax.mail.Transport.send0(Transport.java:254) [com.sun.mail.javax.mail:1.6.2]
at javax.mail.Transport.send(Transport.java:124) [com.sun.mail.javax.mail:1.6.2]
at com.maxboeglsitesassets.core.servlets.RenewablesContactUsFormServlet.sendEmail(RenewablesContactUsFormServlet.java:81) [aem-maxboeglsitesassets-project.core:0.0.1.SNAPSHOT]
at com.maxboeglsitesassets.core.servlets.RenewablesContactUsFormServlet.doGet(RenewablesContactUsFormServlet.java:59) [aem-maxboeglsitesassets-project.core:0.0.1.SNAPSHOT]
at org.apache.sling.api.servlets.SlingSafeMethodsServlet.mayService(SlingSafeMethodsServlet.java:266) [org.apache.sling.api:2.27.6]
at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:342) [org.apache.sling.api:2.27.6]
at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:374) [org.apache.sling.api:2.27.6]
at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:544) [org.apache.sling.engine:2.15.16]

3 Replies

Avatar

Level 6

Configuring mail service at AEM is quite old and matured. Refer to here

 

Your problem of connection timeout sounds to be environmental. There is some firewall or network restriction or antivirus that is blocking. Your networking team should be able to help. Also there are general mistakes people commit while configuring gmail. Checkout here, and here

 

Another gmail setting to watchout 

Go to Gmail > Settings > Other Google Account settings under Accounts and Import > Sign-in & security.

Allow less secure apps: OFF (Means my application is not less secure)

2-Step Verification: Off

App Passwords (Click on it, and Google will generate a 16 characters long password for you, later done, change your gmail password with this 16 char long password (which is without any space)).

 

This is NOT AEM problem, general networking problem, googling and trying different solutions should help. 90% its firewall restrictions. 

Avatar

Level 1

Thanks @sarav_prakash , here we are using the AEM as a cloud service and there is a form for which we have used default.mailService and that is working fine on the environment as well but when we used the transport.send() from javax.mail it is not working.

Avatar

Level 6

Yeah as mentioned, `Couldn't connect to host` is always firewall network issue. If you connect to your networking team, they ll monitor traffic and point why port is blocked. And they should advice how to waive or proxy. This setup is different for organizations. since this is not aem, couldn't really help with this.