Debugging IMAP access of Yahoo in 2018

允我心安 提交于 2019-12-11 08:02:14

问题


I am unable to authenticate IMAP with Yahoo and cannot pinpoint the cause. Can anyone help me to get more information other than the exception below?

"javax.mail.AuthenticationFailedException: [AUTHENTICATIONFAILED] Invalid credentials (Failure)"

Yahoo seems to have had many revisions to authentication over the years so that is why I put the current year in the title. Here is my setup:

On Yahoo: I have enabled less secure apps; I have checked and recheck credentials.

On my linux box: I have proven that IMAP works by using Thunderbird to connect and browse mail.

Here is the code:

  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:


Found the debugging answer. Included debugging on the Session object.

session.setDebug(true);


来源:https://stackoverflow.com/questions/49631965/debugging-imap-access-of-yahoo-in-2018

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!