Skip to content
Advertisement

Unable to Send Mail – javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

We are sending Mail using Spring JavaMailSenderImpl. Following is the configuration

JavaScript

Properties File :-

JavaScript

Console Logs

JavaScript

We are convinced that this is not related to the SSL certificate as there are other web applications deployed in the same server which sends email perfectly with the same configuration. What could be the issue here ?

Advertisement

Answer

JavaScript

You want either mail.smtp.ssl.enable for implicit SSL directly after TCP connect (port 465) or mail.smtp.starttls.enable for explicit SSL using the STARTTLS command (port 25). But with your current properties you set both to true.

This means it will do a TCP connect to port 25 and try a SSL handshake there. This will fail because the server is sending a plain text greeting from the SMTP dialog and not the expected SSL handshake. Thus you get

Unrecognized SSL message, plaintext connection?

To fix it make sure that you either use implicit or explicit SSL but not both depending on the port, i.e. for port 25 mail.smtp.ssl.enable should be false.

Advertisement