Java 邮件发送代码中的SSLHandshakeException

Java 邮件发送代码中的SSLHandshakeException,java,security,email,sslhandshakeexception,Java,Security,Email,Sslhandshakeexception,我正在开发从我的域名向gmail.com发送电子邮件的代码 我得到一个SSLHandshakeException(见下文)。 如何解决这个问题 Exception in thread "main" javax.mail.MessagingException: Could not convert socket to TLS; nested exception is: javax.net.ssl.SSLHandshakeException: sun.security.validator.Vali

我正在开发从我的域名向gmail.com发送电子邮件的代码

我得到一个
SSLHandshakeException
(见下文)。
如何解决这个问题

Exception in thread "main" 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

您没有使用SSL,您正在尝试以普通身份验证发送邮件,而您需要SSL身份验证访问。

您的服务器上是否有防火墙设置?回答此问题时的注释可能会有所帮助: