【问题标题】:Download Email using Gmail Server , 'Authentication Failed'使用 Gmail 服务器下载电子邮件,“身份验证失败”
【发布时间】:2015-08-07 06:28:19
【问题描述】:

我想使用 Gmail 服务器下载电子邮件,首先我需要连接它,我为此使用 Pop3 Gmail 服务器,但出现“身份验证失败”错误。连接代码是:

        Properties properties = new Properties();
    // server setting
    properties.put("mail.pop3.host",host);
    properties.put("mail.pop3.port",port);
    // SSL setting
    properties.setProperty("mail.pop3.socketFactory.class",
            "javax.net.ssl.SSLSocketFactory");
    properties.setProperty("mail.pop3.socketFactory.fallback", "false");
    properties.setProperty("mail.pop3.socketFactory.port",
            String.valueOf(port));
    Session session = Session.getDefaultInstance(properties);
    try {
        // connects to the message store
        Store store = session.getStore("pop3s");
        store.connect(userName, password);    //error at this line

【问题讨论】:

  • 也许,这不起作用@Kennet
  • 错误:javax.mail.MessagingException:连接失败;嵌套异常是:javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException:PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法在 com.sun.mail 中找到请求目标的有效证书路径.pop3.POP3Store.protocolConnect(POP3Store.java:213) 在 javax.mail.Service.connect(Service.java:345) 在 javax.mail.Service.connect(Service.java:226) 在 javax.mail.Service。连接(Service.java:246)
  • 同样的问题,不知道为什么,,"stor.connect(userName,password);"不工作

标签: java download email-attachments gmail-api pop3


【解决方案1】:

问题是由于Gmail中的安全设置,如果你添加

emailSession.setDebug(true);

您实际上会得到一个指向错误消息的链接,https://support.google.com/mail/answer/78754

还发现this

【讨论】:

    【解决方案2】:

    谢谢,它不起作用,问题是 Avast Antivirus,它阻止与邮件服务器的连接。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-31
      • 2012-06-16
      • 2013-11-30
      • 2016-11-13
      • 2016-02-29
      • 2020-11-12
      • 2011-10-14
      • 2015-07-09
      相关资源
      最近更新 更多