在2018年调试雅虎的IMAP访问

时间:2018-04-03 13:57:04

标签: authentication javamail imap yahoo

我无法通过Yahoo验证IMAP,无法查明原因。任何人都可以帮助我获得除下面例外以外的更多信息吗?

“javax.mail.AuthenticationFailedException:[AUTHENTICATIONFAILED]凭据无效(失败)”

多年来雅虎似乎对身份验证进行了很多修改,这就是我将当前年份列入标题的原因。这是我的设置:

在雅虎:我启用了不太安全的应用程序;我已检查并重新检查凭据。

在我的Linux盒子上:我已经证明IMAP可以通过使用Thunderbird来连接和浏览邮件。

以下是代码:

  1  private static final String email_id = "xxxxxxxx@yahoo.com";
  2  private static final String password = {"xxxxxxxx"};
  3 
  4  public static void main(String[] args) {
  5  
  6    Properties properties = new Properties();
  7    //yahoo
  8    properties.put("mail.store.protocol",        "imap");
  9    properties.put("mail.imaps.host","imap.mail.yahoo.com");
 10    properties.put("mail.imaps.port",            "993");
 11    properties.put("mail.imap.ssl.enable",       "true");
 12    properties.put("mail.imap.mail.auth",        "true");
 13                          
 14    try {                 
 15       Session session = Session.getDefaultInstance(properties, null);
 16       Store store     = session.getStore("imaps");
 17       
 18       store.connect(email_id, password);
 19       
 20       ...
 21       
 22       store.close();
 23    } catch (Exception e) {
 24       e.printStackTrace();
 25    }  
 26  } // end of main
 27 }

1 个答案:

答案 0 :(得分:0)

找到调试答案。包含对Session对象的调试。

session.setDebug(true);
相关问题