Import an old mbox file into Thunderbird

I tried to import an old e-mail file from year 2000 or so, using Thunderbird’s ImportExportTools extension. And it failed. I first tried to split the mbox file, but eventually I found that X-Mozilla… headers were at fault! So, the solution is simply to run this command on the file before importing it in Thunderbird:

sed -i.bak '/^X-Mozilla/d' MboxFile

In case someone is interested, here is how I could split the mbox file into multiple eml files:

mkdir files.eml
awk '
BEGIN {f=0; o=""}
function new() {if (f!=0) close(o); f=f+1; o=sprintf("files.eml/%d.eml",f)}
/^From - / {new(); next}
/^X-Mozilla/ {next}
{print >>o}
END {new()}' MboxFile

This worked because each e-mail in my mbox file started with a « From - … » line. I’m not sure this is a universal rule, however.

Ajouter un commentaire

Le code HTML est affiché comme du texte et les adresses web sont automatiquement transformées.

La discussion continue ailleurs

URL de rétrolien : http://yalis.fr/cms/index.php/trackback/91

Fil des commentaires de ce billet