The default mailbox format used by postfix and dovecot is the mbox format. This basically boils down to a single file per user in /var/mail/ with all mails concatenated, one after the other. (Mail in folders other than inbox are stored in ~/mail/)

Mail stored in the Maildir format uses 1 file per mail. Accessing individual mails is faster, but because there are many small files, the disk space overhead is bigger.

The mbox format is fairly simple and compact, but has a couple of problems. For one, being a single flat file it’s easy to append new incoming mails, but it’s not straightforward to remove a mail from the middle of the file. Another problem that I’ve noticed in Thunderbird 3 is that sometimes two mails would appear to be combined. I’d suddenly see another mail’s attachments appearing on a mail without attachments. I’m not sure whether this is a problem with Thunderbird, dovecot, or perhaps a corrupt mbox file?

The steps:

  1. Before we start the conversion exit your mail client.

  2. You should also stop postifx to prevent mail being delivered to the wrong mailbox during conversion: sudo /etc/init.d/postfix stop

  3. The easiest way to convert the mailbox format is to let dovecot do it for us. Make the following changes to /etc/dovecot/dovecot.conf:

mail_location = maildir:~/Maildir
mail_plugins = convert
convert_mail = mbox:~/mail:INBOX=/var/mail/%u

(Search for the settings and change them.)

  1. Apply the changes by restarting dovecot: sudo /etc/init.d/dovecot restart

  2. Now start your mail client. Dovecot will convert the mailbox at login, so this might take a while. Also, chances are the client will start to download all mail again. (There seem to be some scripts that can prevent this.)

  3. Before we start postfix, edit /etc/postfix/ to tell it where to deliver the mail: home_mailbox = Maildir/

  4. Restart postfix: sudo /etc/init.d/postfix start