Protocol error with javax.mail.AuthenticationFailedException appearing intermittently on pop3 connect

764 views Asked by At

I have a javamail program to read emails to my pop3 account at regular intervals. It connects and works successfully most of the times. But, after a while I start getting javax.mail.AuthenticationFailedException and unable to connect it on further calls. And when i shut and start my program it start connecting successfully again with same credentials. For further analysis, I enabled session debug logs. Following is the command trace output:

@2021-05-17 12:36:08.150 !DEBUG      +OK The Microsoft Exchange POP3 service is ready. #27820545
@2021-05-17 12:36:08.150 !DEBUG      CAPA     #27820545
@2021-05-17 12:36:08.150 !DEBUG      +OK       #27820545
@2021-05-17 12:36:08.150 !DEBUG      TOP        #27820545
@2021-05-17 12:36:08.150 !DEBUG      UIDL      #27820545
@2021-05-17 12:36:08.150 !DEBUG      SASL PLAIN         #27820545
@2021-05-17 12:36:08.150 !DEBUG      USER     #27820545
@2021-05-17 12:36:08.150 !DEBUG      STLS       #27820545
@2021-05-17 12:36:08.150 !DEBUG      .               #27820545
@2021-05-17 12:36:08.150 !DEBUG      DEBUG POP3: authentication command trace suppressed          #27820545
@2021-05-17 12:36:50.341 !DEBUG      DEBUG POP3: authentication command failed #27862736
@2021-05-17 12:36:50.342 !DEBUG      QUIT      #27862737
@2021-05-17 12:36:50.342 !DEBUG      -ERR Protocol error. 19   #27862737
@2021-05-17 12:37:50.371 !DEBUG      DEBUG: getProvider() returning javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle]          #27922766
@2021-05-17 12:37:50.371 !DEBUG     DEBUG POP3: mail.pop3.rsetbeforequit: false #27922766
@2021-05-17 12:37:50.371 !DEBUG     DEBUG POP3: mail.pop3.disabletop: false          #27922766 

What could be cause for this? The account service provider is Microsoft Exchange. What does protocol error.19 indicate?

2

There are 2 answers

0
Jonad García San Martín On

I suspect that the authentication credentials supplied for the POP server have expired or you are using the same Session for all of your connections and it expires after a while. But like @JRichardsz says, please attach an snippet of your code and the exception stack.

0
tquadrat On

That it works for some time before it stops working out of a sudden, and that it works again after you just restarted your program allows the assumption that nothing is wrong with your code as such.

Do you connect to a local Exchange server, or to Office365?

The latter imposes several limit values for various service activities, and in case of email you get an authentication failure when one of this limits is hit.

You can configure the same or similar limits on your local Exchange, too, and will get the same error behaviour when you hit them.

In your case I assume that you hit a limit for the number of login attempts within a given period of time. Check what happens if you ping your mail box less frequently.