Converting mailbox format from mbox to Maildir
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:
-
Before we start the conversion exit your mail client.
-
You should also stop postifx to prevent mail being delivered to the wrong mailbox during conversion: sudo /etc/init.d/postfix stop
-
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:
(Search for the settings and change them.)
-
Apply the changes by restarting dovecot: sudo /etc/init.d/dovecot restart
-
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.)
-
Before we start postfix, edit /etc/postfix/main.cf to tell it where to deliver the mail: home_mailbox = Maildir/
-
Restart postfix: sudo /etc/init.d/postfix start