Mutt: too many errors

I'm probably one of the last people on earth who still use a text-mode mail client. Mutt has been my tool of choice for 15 years and apart from certain limitations (hey, it's text mode!), I've never had any problems. Over the last few weeks, however, I've been struggling with a mysterious problem: After a few seconds of use, Mutt would print an error message "too many errors" and exit without further comment.

I suspected a change in my mail provider's IMAP setup, but with the help of a colleague I figured out that I caused the problem myself. Inside the GUI, Mutt did nothing to help me diagnose the problem, but fortunately there's a debug mode that writes a logfile to ~/.muttdebug0:

mutt -d 5

The logfile showed the following problem:

[2012-09-06 09:32:15] Mutt/1.5.21 (2010-09-15) debugging at level 5
[2012-09-06 09:32:32] 4< a0037 NO unknown folder
[2012-09-06 09:32:32] 4< * BYE too many errors
[2012-09-06 09:32:32] Handling BYE
[2012-09-06 09:32:32] too many errors
[2012-09-06 09:32:34] imap_exec: command failed: * BYE too many errors
[2012-09-06 09:32:34] Error polling mailboxes

It turns out that I had a mailboxes statement in my config referencing mail folders that didn't exist on the server anymore. Once in a while, Mutt would poll these mailboxes and fail, increasing an error counter. When the error threshold was reached it would exit.

After removing these references, things went back to normal.