Getting MessagingException: Could not convert socket to TLS when sending mail via SMTP
Looks like something is going wrong in the JDK's SSL support. Perhaps something about the certificate from the server is confusing it. You're using a pretty old version of the JDK. I would try upgrading to a current version to see if that resolves the problem. You can also try enabling some of the low level SSL debugging output in the JDK, as described in the links in the JavaMail SSLNOTES.txt.
Unable to send an email using SMTP (Getting javax.mail.MessagingException: Could not convert socket to TLS;)
I resolved this issue by just commenting out the below property
props.put("mail.smtp.starttls.enable", "true");
and the code got executed with no errors or warning or simply delete this line from the above source code. It is working like a charm till date.
javax.mail.MessagingException: Could not convert socket to TLS exception in JAVA
Try to change the value of the property mail.smtp.socketFactory.class
to javax.net.ssl.SSLSocketFactory
instead of javax.net.ssl.SSLsocketFactory
,
The class name is case sensitive.
For more infromations about connection properties you can look at:
Where to find all available Java mail properties?
Gmail Api in spring boot : javax.mail.MessagingException: Could not convert socket to TLS
I think the reason is that Gmail blocks Access for less secure apps by default for security reasons
check this similar question it's answer may help you
Error sending email with gmail
Java Mailing Logic: Could not convert socket to TLS
Whether SSL/TLS is required or not is controlled by your mail server. If it requires it, you have to use it.
You can set the mail.smtp.ssl.trust property to ignore the certificate issue, or you can fix it as described in the JavaMail FAQ.
Related Topics
Why Is This Java Code in Curly Braces ({}) Outside of a Method
Is There a Way in Java to Convert an Integer to Its Ordinal Name
What to Return If Spring MVC Controller Method Doesn't Return Value
Collection Interface VS Arrays
Write a File in Utf-8 Using Filewriter (Java)
Determine Whether Daylight Savings Time (Dst) Is Active in Java for a Specified Date
Exclude Methods from Code Coverage with Cobertura
What Is the Most Recommended Way to Store Time in Postgresql Using Java
How to Read a Text-File Resource into Java Unit Test
Export PDF Pages to a Series of Images in Java
Qr Code Encoding and Decoding Using Zxing
How to Load an Org.W3C.Dom.Document from Xml in a String
Whats the Best Way to Recursively Reverse a String in Java