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?
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.