1

I have a problem connecting to a SMTP Server with Apache Commons Mail. I have tried everything but the only thing I can find online is for Java Mail. This is my error:

Caused by: 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

I have seen that you can fix the issue on Java Mail with props.put("mail.smtp.ssl.trust", "smtp.gmail.com"); for example, but I can't a equivalent command to use on Apache Commons.

Ângelo Martins
  • 41
  • 1
  • 1
  • 7

1 Answers1

2

If you're really connecting to Gmail, you shouldn't need that. The Gmail certificate will be trusted by the default trust store. If you've configured a non-default trust store, add the Gmail certificate to that trust store using the InstallCert program.

Bill Shannon
  • 29,579
  • 6
  • 38
  • 40