'DEBUG IMAP: AUTHENTICATE PLAIN command result: A3 NO AUTHENTICATE failed

I'm connecting to IMAP server with java code:

        String host      = "outlook.office365.com";
        String port      = "143";
        String username  = "[email protected]";
        String password  = "password";

        Properties props = System.getProperties();

        props.setProperty("mail.imap.port", port);
        props.setProperty("mail.imap.host", host);

        //SSL
        props.setProperty("mail.imap.starttls.enable", "true");

        props.setProperty("mail.imap.ssl.protocols", "TLSv1.2");
        props.setProperty("mail.imap.socketFactory.class", "com.boomi.connector.mailsdk.connection.MailSSLSocketFactory");
        props.setProperty("mail.imap.socketFactory.fallback", "true");
        props.setProperty("mail.imap.socketFactory.port", port);

        Authenticator auth = new Authenticator()
        {
            public PasswordAuthentication getPasswordAuthentication()
            {
                return new PasswordAuthentication(username , password);
            }
        };
        Session session = Session.getInstance(props, auth);
        session.setDebug(true);
        System.out.println(session);
        Store store = session.getStore("imap");

        System.out.println(store);

        store.connect();

Problem number one:

  1. it takes imap store as imap://[email protected]
  2. failing to connect

log:

DEBUG: setDebug: JavaMail version 1.6.2 javax.mail.Session@6433a2 DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle] DEBUG IMAP: mail.imap.fetchsize: 16384 DEBUG IMAP: mail.imap.ignorebodystructuresize: false DEBUG IMAP: mail.imap.statuscachetimeout: 1000 DEBUG IMAP: mail.imap.appendbuffersize: -1 DEBUG IMAP: mail.imap.minidletime: 10 DEBUG IMAP: enable STARTTLS DEBUG IMAP: closeFoldersOnStoreFailure imap://[email protected] DEBUG IMAP: protocolConnect returning false, host=outlook.office365.com, user=windows_user, password= DEBUG IMAP: trying to connect to host "outlook.office365.com", port 143, isSSL false OK The Microsoft Exchange IMAP4 service is ready. [QQBNADYAUABSADAANABDAEEAMAAwADEANAAuAGUAdQByAHAAcgBkADAANAAuAHAAcgBvAGQALgBvAHUAdABsAG8AbwBrAC4AYwBvAG0A] A0 CAPABILITY CAPABILITY IMAP4 IMAP4rev1 LOGINDISABLED STARTTLS SASL-IR UIDPLUS MOVE ID UNSELECT CHILDREN IDLE NAMESPACE LITERAL+ A0 OK CAPABILITY completed. DEBUG IMAP: protocolConnect login, host=outlook.office365.com, [email protected], password= A1 STARTTLS A1 OK Begin TLS negotiation now. A2 CAPABILITY CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=XOAUTH2 SASL-IR UIDPLUS MOVE ID UNSELECT CHILDREN IDLE NAMESPACE LITERAL+ A2 OK CAPABILITY completed. DEBUG IMAP: AUTH: PLAIN DEBUG IMAP: AUTH: XOAUTH2 DEBUG IMAP: AUTHENTICATE PLAIN command trace suppressed DEBUG IMAP: AUTHENTICATE PLAIN command result: A3 NO AUTHENTICATE failed.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source