I try to write a app to automatically re-organize my mails (thunderbird).
The first thing I try is to re-create my folders tree, once for each year.
So i need to read mbox files and rewrite them
import mailbox mbx=mailbox.mbox("./in_mbox") mbx.lock() of=open("out_mbox", "w") for k, m in mbx.iteritems(): of.write(m.as_string()) mbx.unlock() of.close()
My problem is that during this process, I lose the "From " line between original file mails
From - Mon Jun 16 08:54:05 2008 X-Account-Key: account2 X-UIDL: 919-1206101190 X-Mozilla-Status: 0001 X-Mozilla-Status2: 00000000 Return-path: <email@example.com> Received: from ...
X-Account-Key: account2 X-UIDL: 919-1206101190 X-Mozilla-Status: 0001 X-Mozilla-Status2: 00000000 Return-path: <firstname.lastname@example.org> Received: from ...
"From " line is missing.
I try to get it with everything i could in email.Message object (get_all, get_unixfrom...) but i couldn't find the solution.
Does anyone know what i have missed ?