0 Replies Latest reply: Apr 22, 2013 6:49 AM by 1004593 RSS

    Login failed exception while using iMap

    1004593
      I am gtting the below exception while trying to connect using imap.

      Please see the code below:

      Session session;
                Store store;
                Folder folder;
                Message[] messages;
                Properties properties;
                String username;
                String password;
                store = null;
                username = null;
                password = null;
                Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
                properties = new Properties();
                properties.put("port", "993");
                properties.put("protocol", "imap");
                properties.put("host", "outlook.office365.com");
                // set this session up to use SSL for IMAP connections
           properties.setProperty("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
           // don't fallback to normal IMAP connections on failure.
           properties.setProperty("mail.imap.socketFactory.fallback", "false");
           // use the simap port for imap/ssl connections.
           properties.setProperty("mail.imap.port", "993");
           properties.setProperty("mail.imap.socketFactory.port", "993");
           properties.setProperty("mail.imap.socketFactory.timeout", "9993");
           properties.setProperty("mail.imap.partialfetch", "false");
           properties.setProperty("mail.imap.auth.plain.disable","true");
           properties.setProperty("mail.imap.starttls.enable", "true" );
           properties.setProperty("mail.imap.ssl.enable", "true");
           properties.setProperty("mail.imap.auth.ntlm.disable", "true");
           properties.setProperty("mail.imap.auth.gssapi.disable", "true");


                session = Session.getDefaultInstance(properties, null);
                session.setDebug(true);



                int port= Integer.parseInt(properties.getProperty("port"));


                System.out.println("host : "+properties.getProperty("host"));
                System.out.println("protocol : "+properties.getProperty("protocol"));
                System.out.println("port : "+port);

                URLName urln = new URLName(properties.getProperty("protocol"),properties.getProperty("host"), port, null,
                               "responder2@emlogis.com", "Emlogis123");
                System.out.println("urln : "+urln);
                store = new IMAPSSLStore(session, urln);
                System.out.println("store : "+store);



                try {


                     store.connect(properties.getProperty("host"),993, "responder2@emlogis.com", "Emlogis123");
                     System.out.println("-----------Connected successfully-------------!");

      }
      catch (MessagingException e) {
                     e.printStackTrace();
                }

           }



      DEBUG: setDebug: JavaMail version 1.4.5-SNAPSHOT
      host : outlook.office365.com
      protocol : imap
      port : 993
      urln : imap://responder2%40emlogis.com:Emlogis123@outlook.office365.com:993
      DEBUG: mail.imap.partialfetch: false
      DEBUG: mail.imap.statuscachetimeout: 1000
      DEBUG: mail.imap.appendbuffersize: -1
      DEBUG: mail.imap.minidletime: 10
      DEBUG: disable AUTH=PLAIN
      DEBUG: disable AUTH=NTLM
      DEBUG: enable STARTTLS
      store : imap://responder2%40emlogis.com@outlook.office365.com:993
      DEBUG: trying to connect to host "outlook.office365.com", port 993, isSSL true
      * OK The Microsoft Exchange IMAP4 service is ready. [QgBZADIAUABSADAANgBDAEEAMAA
      wADUALgBuAGEAbQBwAHIAZAAwADYALgBwAHIAbwBkAC4AbwB1AHQAbABvAG8AawAuAGMAbwBtAA==]
      A0 CAPABILITY
      * CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN UIDPLUS CHILDREN IDLE NAMESPACE LITERAL+

      A0 OK CAPABILITY completed.
      DEBUG IMAP: AUTH: PLAIN
      DEBUG: protocolConnect login, host=outlook.office365.com, user=responder2@emlogi
      s.com, password=<non-null>
      A1 LOGIN responder2@emlogis.com Emlogis123
      A1 NO LOGIN failed.
      javax.mail.AuthenticationFailedException: LOGIN failed.
      at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:660)
      at javax.mail.Service.connect(Service.java:295)
      at readMail.main(readMail.java:79)