Search code examples
javacentosjakarta-mailimapdovecot

javax.mail.MessagingException: * BYE Internal error occurred


I am trying to install JavaMail on a CentOS 7 development machine using localhost only for the emails. Towards this end, I have installed dovecot, postfix, and mailx. I just installed dovecot using the instructions in this tutorial. But my JavaMail test code has been giving me all sorts of authentication errors when I try to read an inbox. How can I resolve these authentication errors so that I can log in?

At first, I was getting errors related to not finding a certificate, but I was able to resolve all those errors by commenting out any mention of ssl in the config files, by changing the protocol to imap instead of imaps, and by changing authentication to plain instead of login. (I can do all these things because it is a development machine and I just want to get JavaMail working before adding security in afterwards.) But after all those changes, I am still getting:

javax.mail.MessagingException: * BYE Internal error occurred.   
Refer to server log for more information.  

The line of code that throws the error is:

store.connect("localhost.localdomain", "root", "somepassword");

Note that typing hostname in the CentOS terminal results in localhost.localdomain.

The /var/log/maillog records are:

Jan  8 16:08:01 localhost dovecot: imap-login: Login: user=<root>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, mpid=7965, secured, session=<yb8l8ywMdwB/AAAB>
Jan  8 16:08:01 localhost dovecot: imap: Error: user root: Invalid settings in userdb: userdb returned 0 as uid
Jan  8 16:08:01 localhost dovecot: imap: Error: Invalid user settings. Refer to server log for more information.

Solution

  • Dovecot won't let you log in as root. Use some other user and userid.