Migrating a Mail Archive from Mbox to IMAP

It’s been several years that I store all my email in Kmail. It used to be Outlook back in 2000, but I soon got fed up and converted to a Linux box where the .pst format was quite useless. I used a nifty utility to do the conversion on a Windows box, and everything worked just fine.

Now it’s time to move again. This server has a new IMAP implementation that polls my POP3 provider every minute, performs filtering, then allows me to connect from anywhere. That’s very usable, especially considering that I always run the email client at home and it would be quite annoying not to be able to read home email during the day.

Problem: None of the current email clients know how to move a repository to IMAP. Oddly enough, Outlook can do it no problem, while the open source world entirely ignores the problem. That’s quite silly, since a conversion utility is quite easy to write.

1. Convert Maildir to Mbox

I had chosen a very unfortunate setup in which maildir and mbox folders were mixed in colorful harmony. I didn’t like trying to convert a promiscuous system, so I set out to convert from one format to the other.

NOTE: This step is entirely optional, as the routines used later to convert from Mbox to IMAP work in principle just as well with maildir folders.

There are several utilities to convert files from the Maildir to the Mbox format. There are many, many more that convert from Mbox to Maildir, and that might have been the better option; but I stuck with the original idea.

The script can be found here. maildir2mbox works very well, with one major caveat: it creates all mboxes in the root mail folder instead of the original location. This is annoying because if you happen to have two maildir folders in different locations, one will convert on top of the other and you lose all information. Additionally, you’d rather have the mbox in the original location, anyway.

I slightly modified the script to do as above, which was quite simple.

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.