mb2md: convert mailbox to Maildir
The traditional Unix mailbox format -- often called "mbox" -- sucks. Maildir, a format invented by Dan Bernstein of qmail fame, sucks much, much less. Unfortunately, all the tools that I could find to convert mbox files to maildirs suck even more than the mbox format itself. (Eg. they do a bogus/incomplete conversion and then delete the input mbox without warning -- that sort of thing.)
So I wrote my own mbox-to-maildir conversion tool, called
mb2md (all the obvious names were taken). Bragging points:
mb2mddoes not destroy your valuable email. It insists that the output maildir not exist when you start, so you know that the output maildir exactly matches the input mbox. More importantly, it does not remove the input mbox when finished -- so if you decide you don't like what
mb2mddid, you can fallback to your old mbox.
mb2md(or rather, the
addtomaildirscript that does the real work) takes considerable pains to preserve all useful information from your mbox file. Specifically, new/old/read messages in the mbox remain new/old/read in the maildir. Also, it attempts to figure out the delivery time of each message in the mbox, and sets the mtime of the corresponding message file in the maildir from it -- that way, you can easily sort the maildir by delivery time.
addtomaildirscript, which does the real work of analyzing each message from the mbox and adding it to the maildir (requires Python 2.2 or greater)
mb2mdshell script itself
chmod +x mb2md addtomaildir
Thanks to the following people for patches and so forth:
reformailin addition to
addtomaildirto support Postfix)
Share and enjoy!
A couple of people have reported a peculiar problem with
addtomaildir, it runs it as a shell script, not as a Python
script. Unsurprisingly, this does not work very well. (Yes, in both
cases I told the person to make sure
executable, and in both cases it was.) Unfortunately, since I don't
mb2md at all (it's a one-off tool: convert your
mailboxes and you're done with it), I have no time to investigate. But
there's an alternative: Juri Haberland's
. Give it a try.