February 28, 2007

Dovecot Invalid Messageset Error and Solution

Though working for a long time, while trying to read their mail, two of our Thunderbird IMAP users suddenly received the error: "The current command did not succeed.  The mail server responded: Invalid messageset: -2147483648:*."

A bit of research revealed that Dovecot versions 0.99.13 and earlier have an interesting bug in which the X-UID header for emails can get too large, and therefore cannot be processed by Dovecot.  (Information can be found here (translated from Japanese) and here).

Unfortunately, to fix this (in my case under Fedora Core), you have to do some work for every user who encountered the error:

  1. Turn off sendmail and dovecot.  In my case:
    • /etc/init.d/MailScanner stop
    • /etc/init.d/dovecot stop
  2. For every user experiencing the problem (say jdoe), remove the offending X-UID lines from the email and reset their imap indices:
    • grep -v ‘^X-UID: ‘ jdoe > jdoe2
    • grep -v "^X-IMAPbase: " jdoe2 > jdoe
      • Note: this step was missing from the other online articles
    • rm jdoe2
    • chown jdoe:mail jdoe
    • chmod 660 jdoe
    • rm ~jdoe/mail/.imap/.imap.index*
  3. Then restart dovecot and the mail server.  In my case:
    • /etc/init.d/MailScanner start
    • /etc/init.d/dovecot start

The next time the user hits their INBOX through IMAP, unfortunately Thunderbird will need to reload all of the messages, but at least it will work again.

Aparently upgrading Dovecot to 0.99.14 or later will avoid the issue in the future.

Hope this helps.

2 responses to “Dovecot Invalid Messageset Error and Solution

  1. didnt work for me.. 🙁 where do you run these commands?
    # grep -v ‘^X-UID: ‘ jdoe > jdoe2
    # grep -v “^X-IMAPbase: ” jdoe2 > jdoe
    thanks…
    tom

  2. This worked perfectly! Made me look like a hero to our CEO on a Saturday while he was waiting for an important email on a business trip! You rock!
    Thanks
    DT

Comments are closed.