Convert maildir to mbox

Note, there is a short story before the main course.

I recently had a cus­tomer leave. It’s never good to lose a cus­tomer. They left not because of any ser­vice issues but because its hard for them to under­stand that I am not a web designer. I pro­vided host­ing ser­vice for them, and I tried to make it clear that they should find a web desinger and some­one to main­tain their site because that is not some­thing I spe­cial­ize in or have any inter­est in doing. At any rate this of course leads to them find­ing a designer who wants to move their site to some other host. I have no prob­lems with that what­ever makes the main­tainer happy since he is the one who will have to sup­port it.

My issue comes when I am asked to han­dle things like mail. The web­de­vel­oper seems to not under­stand how mail works and appears to not be com­fort­able with migra­tion. I reminded the cus­tomer to make sure he had a plan in place for their mail (it’s not my respon­si­bil­ity). I switched the dns on my end and changed the name­servers with the reg­is­trar so the cut would be as quick as pos­si­ble. Days later after sort­ing the mail issue on their end I was asked about their old email. I had just the day prior ter­mi­nated their accounts so I had to dig through some back­ups to find the mail. I obliged and sent a tar.gz of the entire maildir. Now their new guy says he isnt com­fort­able restor­ing the mail prob­a­bly because he has no clue how to deal with maildir on the new host (net­work solu­tions). Mind you I am tak­ing some lib­erty here because he com­plained to me I didnt tell him how to migrate the mail. I had just assumed he would use a tool like imap­sync or even hook up both accounts in a mail client and man­u­ally trans­fer the mail from the old server to the new one. So that being the case I say he doesn’t under­stand how mail works, and its his fail for accept­ing respon­si­bil­ity to migrate a site and host­ing ser­vices with­out plan­ning how to do so.

That brings us to the main course or as I look at all the text above per­haps it should be desert.

I con­verted the maildir to mbox for the cus­tomer in the hopes the new guy can fig­ure out how to load the mbox into a mail client and upload the mail to the new server for the cus­tomer. Per­haps I am being a bit petty mak­ing him do it. I don’t feel too bad I have already gone way past nor­mal cus­tomer ser­vice with this cus­tomer, and even gave them sev­eral months of host­ing for free (I for­got to bill them and told them not to worry about it). Not to men­tion the time I have spent going to their office to trou­bleshoot a work­sta­tion because “the inter­net was bro­ken” which I also did not charge for. So maybe I am just inflict­ing a bit of pain on the new guy, but I hope he learns from the experience.

So how did I con­vert the maildir to mbox? I used for­mail which is pro­vided by procmail.

for i in maildir/cur/*;do formail -I "Status: RO" <"$i" >>mbox;done
for i in maildir/new/*;do formail -I Status: <"$i" >>mbox;done

You will want to do that for each maildir (don’t for­get the .Sub­folder direc­to­ries). And remem­ber each “folder” or maildir would be a dif­fer­ent mbox file. So if you wanted to save sent mail as well …

for i in maildir/.Sent/cur*;do formail -I "Status: RO" <"$i" >>sent;done
for i in maildir/.Sent/new/*;do formail -I Status: <"$i" >>sent;done

2 Comments

  • Too funny! I wrote an entire arti­cle for SysAd­min mag­a­zine about the reverse a while back. Gotta get that up on my web­site now that SysAd­min is no more. Any­way here’s the some­what con­vo­luted script I used: http://www.hollenback.net/writings/Mbox2Maildir

  • Yeah, I was sad when SysAd­min mag went out of busi­ness. It was even pub­lished right here in Lawrence KS. Pretty much every­one from SysAd­min went over to Linux Pro Mag­a­zine from what Ive heard (Linux Pro Mag­a­zine is also pub­lished here in Lawrence).

Leave a Reply

Your email is never shared.Required fields are marked *

To submit your comment, click the image below where it asks you to...
Clickcha - The One-Click Captcha