javax.mail.AuthenticationFailedException: LOGIN failed

Copper Contributor

We are facing issues to connect to the Office365 mailbox from java class on/from DB server(Oracle 11.2.0.4.0).The following error is thrown

javax.mail.AuthenticationFailedException: LOGIN failed.
        at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java)
        at javax.mail.Service.connect(Service.java)

1. The same code on other server is failing for the same mailbox.
2. The same code on the same server is failing for other similar      mailbox.
3. java.net.SocketPermissions for connect,resolve for outlook.office365.com      are enabled to the DB user
4. Port = 993, protocol = IMAP, server= outlook.office365.com, JDK on DB server: 1.6.0_43, JavaMail Version tried 1.3.2  / 1.3.5  / 1.5.6

Following is the code used to set IMAP properties:
       private Properties getIMAPProperties(String protocol, int port)
        {
               Properties props = System.getProperties();
               props.put("mail.imap.host", "outlook.office365.com");
               final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";

               if (protocol.equalsIgnoreCase("IMAP") || protocol.equalsIgnoreCase("IMAPS"))
               {
                       // Set manual Properties
                       props.setProperty("mail.imap.socketFactory.class", SSL_FACTORY);
                       props.setProperty("mail.imap.socketFactory.fallback", "false");
                       props.setProperty("mail.imap.port", "993");
                       props.setProperty("mail.imap.socketFactory.port", "993");
                       props.setProperty("mail.imap.auth.plain.disable", "true");
                       props.setProperty("mail.imap.auth.gssapi.disable", "true");
                       props.setProperty("mail.imap.auth.ntlm.disable", "true");
                       props.setProperty("mail.imap.ssl.enable", "true");
               }
              return props;
        }


Below is the excerpt of the Store usage in the Java code on DB server
 import javax.mail.Store;
 Store store = null;
 store = session.getStore(protocol.toLowerCase()); --protocol = IMAP
 store.connect(server, port, username, password);  --ERROR is thrown at this step

1 Reply
I encountered the same problem, how to solve it