Import an old mbox file into Thunderbird
Par Yves le samedi 24 septembre 2016, 21:00 - Lien permanent
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.