There is a handy utility for converting mbox style mailboxes into maildir format at http://batleth.sapienti-sat.org/projects/mb2md/
To convert all of the mailboxes on your server:
Edit /etc/sudoers and comment out the env_keep section. These variables make it so that the sudo command keeps some environment variables and tries to put things in the wrong directory.
Download mb2db, unzip it, and copy the binary to /bin (where all users can access it)
# wget http://batleth.sapienti-sat.org/projects/mb2md/mb2md-3.20.pl.gz # gunzip mb2db-3.20.pl.gz # cp mb2db-3.20.pl.gz / bin
Then run this command to convert all of the mailboxes into maildir format.
cd /var/spool/mail for username in `ls`; do echo $username; sudo -u $username /bin/mb2md -m -d Maildir; done
That will create a directory called Maildir in each user’s home directory. Then just configure your MTA to deliver mail there, and your IMAP server to pick it up there
In postfix, add this to /etc/postfix/main.cf
home_mailbox = mail/
And in Dovecot, change this in /etc/dovecot.conf
Now you can edit /etc/sudoers and uncomment the env_keep section.
3 thoughts on “Converting mbox’s to maildir format”
Very cool. When I switched I think I lost most of my mail because I didn’t know this. I have some kinda mail server running on my basement linux box (that sends through my ISP’s smtp) and it’s a huge mystery to me. So many parts that I set up so long ago. If it ever goes down I’ll have to reinvent the wheel. 🙂
I am using sendmail as MTA.
How to configure sendmail to save mail to maildir format.
I don’t use sendmail much, but it seems like you should be able to have sendmail use procmail as LDA which is able to save in Maildir format.