zoukankan      html  css  js  c++  java
  • javax.mail.MessagingException: Could not convert socket to TLS

    报错代码

    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

    首先有道翻译后看着好像是证书问题。然后百度了下。看到很多人遇到这些问题,就一个个试一下

    原先获取 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);

    后来试下加上了 代码(host是邮箱服务器地址),可以发送了。网上说的大概意思就是设置服务是可以信任的,不需要安全证书

    props.put("mail.smtp.ssl.trust", host);

    如果还不可以可能就是调用ssl加密 ,网上搜下怎么发送ssl加密的发送邮件方法

    或者试试创建session的其他方法

    Session session = Session.getInstance(props, new javax.mail.Authenticator()
    { protected PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication(username, password); } }
    );

  • 相关阅读:
    tctip demo页面>
    tctip demo页面>
    tctip demo页面>
    tctip demo页面>
    tctip demo页面>
    tctip demo页面>
    tctip demo页面>
    tctip demo页面>
    tctip demo页面>
    sql 随笔
  • 原文地址:https://www.cnblogs.com/zjf6666/p/12616902.html
Copyright © 2011-2022 走看看