How to Convert a backup of old e-mails from Mbox to Maildir?

1.1k views Asked by At

I had an old mailserver (squirrelmail) and it went down but I had a backup of all the messages delivered to all the e-mails, and now I created a new server (Iredmail)

The problem is that the files I have at the moment are in Mbox format as in every user has a big text file that has all the e-mails they've recieved before. And (Iredmail) has a Maildir system, I want to convert the old files then add them to the new system so users can view their old e-mails as well.

2

There are 2 answers

0
jstedfast On

I'd recommend downloading GMime and then writing a small c/c++ program to use this library to parse your mbox files and then save each email message individually into maildir files.

You can read about the maildir format at http://cr.yp.to/proto/maildir.html - it's fairly simple.

Parsing mbox files using GMime is dead simple - you can take a look at test-mbox.c to get started.

Most Linux distributions already include gmime packages and you can install gmime via homebrew on Mac OS X.

0
phil On

What about

reformail -s maildrop < mbox

You need to setup maildrop, basically a file named .mailfilter with this line:

to "$HOME/.maildir/"