Rewriting mail headers
John E. Barham
jbarham at jbarham.com
Tue Jan 21 20:27:35 EST 2003
> For diagnostic purposes I need to rewrite the subject field of the parsed
> message adding some characters.
>
> Is there a way (I'm using the email package) to do this with some python
> module?
>From the email package documentation:
"Message objects provide a mapping style interface for accessing the
message headers"
so you can just do this:
>>> import email
>>> msg = email.message_from_file(open("test.eml"))
>>> msg["subject"] = "New subject"
>>> print msg.as_string()
More information about the Python-list
mailing list