A3 BAD User is authenticated but not connected. RRS feed

  • Question

  • I am trying to read mail from exchange server using IMAP protocol. I have implemented the code. But following exception occurs while executing the code.This exception occurs occasionally, I didn't get the reason why this is happening.

    javax.mail.MessagingException: A3 BAD User is authenticated but not connected.;
      nested exception is:
    com.sun.mail.iap.BadCommandException: A3 BAD User is authenticated but not connected.
    at agent.client.attributeGroups.SendReceive.readMailAndReply(
    at agent.client.attributeGroups.MailQueue.calculateTime(
    at agent.client.MainClass$
    at java.util.concurrent.Executors$
    at java.util.concurrent.FutureTask.runAndReset(
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(
    at java.util.concurrent.ScheduledThreadPoolExecutor$
    at java.util.concurrent.ThreadPoolExecutor.runWorker(
    at java.util.concurrent.ThreadPoolExecutor$

    Properties props = new Properties();
           props.put("mail.imap.auth", "true");
           props.put("mail.imap.ssl.enable", "true");
           props.put("", "");
           props.put("mail.imap.port", "993");
           props.put("mail.transport.protocol", "imap");  
           props.put("mail.imap.auth.plain.disable", true);
           props.put("mail.imap.auth.ntlm.disable", true);
           props.put("mail.imap.auth.gssapi.disable", true);

         //Get session object by passing credentials.
           Session session = Session.getDefaultInstance(props, 
       new javax.mail.Authenticator(){
           protected PasswordAuthentication getPasswordAuthentication() {
               return new PasswordAuthentication(
    mailId, mailPass);}});

        //Creating IMAP store and connecting it to Mailbox using credentials.   
        store = session.getStore("imap");
        store.connect(mailId, mailPass);

            //Getting mailbox mails.
    inbox = store.getFolder("INBOX");; 
    int totalMailCount = inbox.getMessageCount();

    //Reading all mails to Message array.
    Message[] messages = inbox.getMessages(1, totalMailCount);
            for (Message mail : messages) 
    Address[] fromAddresses = mail.getFrom();
    String mailFrom = fromAddresses[0].toString();
    String mailSubject = mail.getSubject();



    Please suggest me some suggestions to resolve the exception.                                                                                                                                            

    Monday, May 30, 2016 1:27 PM