title: Sending an email in Java with commons-mail
body: <p>So I'm trying to send a code to my email with Java. I started out with javax.mail but remember I had problems with it last time I used it so I moved on to Apache Commons Mail.</p>
  
  <p>I'm getting a bunch of errors though. On SSL, I'm getting a <code>java.net.SocketTimeoutException</code> and on TLS, I'm getting a handful of errors:</p>
  
  <pre><code>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
      at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:2000)
  
  Caused by: 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
  
  Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
  
  Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
  </code></pre>
  
  <p>When I did a quick Google search, I found <a href="https://stackoverflow.com/questions/9619030/resolving-javax-net-ssl-sslhandshakeexception-sun-security-validator-validatore">this question</a>. Now because I'm a complete idiot, I do not understand the answer.</p>
  
  <p>What can I do to resolve the errors? Whether it be preventing the Timeout on SSL or the others on TLS.</p>
  
  <p><strong>EDIT:</strong> I do not have a problem sending emails and <code>MessageException</code> is NOT my problem so please stop answering with that.</p>