How to make a Java web application running on WildFly send emails using a Zoho email account?

Viewed 40

I'm trying to make my java web application send e-mails using my Zoho mail account. The application runs in WildFly 26.1.1 server using Java 11.0.15. The WildFly configuration is:

<mail-session name="xyz2ap112-mail-session" debug="true" jndi-name="java:jboss/mail/xyz2ap112MailerBeanSession">
    <smtp-server outbound-socket-binding-ref="zoho-mail-smtp" ssl="true" username="showcase@proyecto-adalid.org" password="the actual password"/>
</mail-session>

<outbound-socket-binding name="zoho-mail-smtp">
    <remote-destination host="smtppro.zoho.com" port="465"/>
</outbound-socket-binding>

It looks just like the configuration that used to work for GMail (until Google banned the Less secure applications). The application throws an exception when connecting to Zoho. I uploaded the whole exception to https://drive.google.com/file/d/18AtJTGBVb3f6HQKTFqDxuavS-JknIJrU/view?usp=sharing and also to https://pastebin.com/Rq0qZDY1. These are just the "Caused by" messages:

Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtppro.zoho.com, port: 465;
Caused by: javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake
Caused by: java.io.EOFException: SSL peer shut down incorrectly

I have also tried using TLS and port=587 instead of SSL and port=465, with both smtppro.zoho.com and smtp.zoho.com. Same exception. Enabling the debug for the session I got these messages:

DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]
DEBUG SMTP: need username and password for authentication
DEBUG SMTP: protocolConnect returning false, host=smtppro.zoho.com, user=showcase@proyecto-adalid.org, password=<null>
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtppro.zoho.com", port 465, isSSL true

It really bothers me that it says password=<null> even though the password is present in the configuration (mail-session/smtp-server). But I guess I would get a different exception for missing or invalid password.

I would really appreciate if someone can help me find a solution to this problem.

0 Answers
Related