title: javax.mail.AuthenticationFailedException: AUTHENTICATE failed. IMAP Store is not connecting
body: <p>I am not able to connect to IMAP store . It was working earlier now its throwing below error</p>
  
  <pre><code>javax.mail.AuthenticationFailedException: AUTHENTICATE failed.
      at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:474)
      at javax.mail.Service.connect(Service.java:275)
      at javax.mail.Service.connect(Service.java:156)
      at javax.mail.Service.connect(Service.java:176)
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>Properties properties = new Properties();
  properties.put("mail.imap.host", "outlook.office365.com"));
  properties.put("mail.imap.port", "993");
  properties.setProperty("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
  properties.setProperty("mail.imap.socketFactory.fallback", "false");
  properties.setProperty("mail.imap.socketFactory.port", String.valueOf("993")));
  session = Session.getInstance(properties);
  store = session.get("imap");
  store.connect(username,password);
  </code></pre>
  
  <p>I checked all the links , i tried few solutions suggested but they dint work .</p>
  
  <p>Debug Info.</p>
  
  <pre><code>  DEBUG: JavaMail version 1.4ea
      DEBUG: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.8.0_112\jre\lib\javamail.providers (The system cannot find the file specified)
      DEBUG: !anyLoaded
      DEBUG: not loading resource: /META-INF/javamail.providers
      DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
      DEBUG: Tables of loaded providers
      DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
      DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}
      DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
      DEBUG: !anyLoaded
      DEBUG: not loading resource: /META-INF/javamail.address.map
      DEBUG: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.8.0_112\jre\lib\javamail.address.map (The system cannot find the file specified)
      DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc]
      DEBUG: mail.imap.fetchsize: 16384
      * OK The Microsoft Exchange IMAP4 service is ready. [TQBBADEAUABSADAAMQAwADEAQwBBADAAMAA2ADcALgBJAE4ARABQAFIARAAwADEALgBQAFIATwBEAC4ATwBVAFQATABPAE8ASwAuAEMATwBNAA==]
      A0 CAPABILITY
      * CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=XOAUTH2 SASL-IR UIDPLUS ID UNSELECT CHILDREN IDLE NAMESPACE LITERAL+
      A0 OK CAPABILITY completed.
      IMAP DEBUG: AUTH: PLAIN
      IMAP DEBUG: AUTH: XOAUTH2
      DEBUG: protocolConnect login, host=outlook.office365.com, user=pavkumar0@publicisgroupe.net, password=&lt;non-null&gt;
      A1 AUTHENTICATE PLAIN
      + 
      cGF2a3VtYXIwQHB1YmxpY2lzZ3JvdXBlLm5ldABwYXZrdW1hcjBAcHVibGljaXNncm91cGUubmV0AFNyaWRoYWJ2cmsrMTM=
      A1 NO AUTHENTICATE failed.
      javax.mail.AuthenticationFailedException: AUTHENTICATE failed.
          at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:474)
          at javax.mail.Service.connect(Service.java:275)
          at javax.mail.Service.connect(Service.java:156)
  </code></pre>