When sending an email using JavaMail, I get this exception:
org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Can't send command to SMTP host;
nested exception is:
javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake. Failed messages: javax.mail.MessagingException: Can't send command to SMTP host;
I am using Tomcat 8 in which I have these arguments added:
-Dcatalina.home=C:\Development\apache-tomcat-8.5.12
-Dcatalina.base=C:\Development\apache-tomcat-8.5.12
-Djava.io.tmpdir=C:\Development\apache-tomcat-8.5.12\temp
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file=C:\Development\apache-tomcat-8.5.12\conf\logging.properties
-XX:PermSize=128m
-XX:MaxPermSize=512m
-XX:+CMSClassUnloadingEnabled
-XX:+UseG1GC
-Dmail.smtp.starttls.enable=true
-Dmail.debug=true
-Dhttps.protocols=TLSv1.1,TLSv1.2
My java mail properties are:
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">true</prop>
<prop key="mail.smtp.debug">true</prop>
<prop key="mail.smtp.starttls.enable">true</prop>
</props>
</property>
I am using Spring Java Mail v.3.2.2.
The weirdest thing is that this configuration has been properly working for years but now around suddenly 80% of the emails are not being sent due to this. However, the other 20% of the emails are sent as usual.
I have reviewed the configuration in the remote server and nothing has been changed.
Thank you to all those who replied.
It appears that all the problem was cause by a change on Microsoft policies regarding the basic authentication for their tenants.
After some changes on the account settings, all is back to normal and the emails are sent again.