I'm unable to save a UnixMailbox correctly

Grzegorz Adam Hankiewicz gradha at terra.es
Wed Jan 30 00:39:00 CET 2002

Hi.  I am trying to write a script which opens a unix mailbox file
through the mailbox module. Then, retrieves all the messages with
.next() and goes through each one and it's headers checking some
things. Finally, I want to open  another file and write the results as
another unix mailbox.  The code I am using to save each message is:   
for f in mail.headers: file.write(f)   mail.rewindbody()   for f in
mail.fp.readlines(): file.write(f)  ...being mail an rfc822 object
returned by mailbox' next method. The problem  is that the written
file lacks the initial "From: ", which I am unable to get from the
rfc822 object.  Basically, why doesn't rfc822 have some
dump_raw_lines() method which returns a list of lines (those exactly
read in first place) to recreate the message?  And how could I get
over the file parameter of mailbox.UnixMailbox to feed it lines from
standard input instead of a physical file?  PD: Please cc your answers
to gradha at terra.es. --  Grzegorz Adam Hankiewicz

More information about the Python-list mailing list