Open source software supply chain lighting plan, waiting for you>>>
Error code
javax.mail.MessagingException: Could not convert socket to TLS;
nested exception is: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
First of all, Youdao looks like a certificate problem after translation. Then Baidu took a look. See a lot of people encounter these problems, try one by one
The original way to get SMTP
Properties props = new Properties();
props.put(“mail.smtp.host”, host);
props.put(“mail.smtp.starttls.enable”, “true”);
props.put(“mail.smtp.auth”, “true”);
Session session = Session.getDefaultInstance(props);
Later try to add the code (host is the address of the mailbox server), you can send it. The general meaning on the Internet is that the setting service can be trusted and does not need a security certificate
props.put(“mail.smtp.ssl.trust”, host);
If not, it is possible to call SSL encryption and search on the Internet how to send SSL encrypted e-mail
Or try another way to create a session
Session session = Session.getInstance(props, new javax.mail.Authenticator()
{ protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password); } }
);