Writing redirected e-mail to file

David Porter jcm at bigskytel.com
Tue Mar 13 08:50:03 EST 2001


* Jacobus van der Merwe <jacobus at geo.co.za>:

> I use sendmail to redirect e-mails to a certain e-mail address to a
> script.
> This script must 'look' at the headers and body of the e-mail, and then
> write the e-mail body to a file.
> 
> I can't figure out exactly how to do this:
> 
> I use rfc822.Message to get the headers, but how do I get the body?

Use fp.read() in rfc822.Message. 

> Can one use mimetools.Message?   What does 'fp' in mimetools.Message
> parameters mean?  Once read with mimetools.Message, how do I write
> it to a textfile.

f = open('some_file', 'w')
f.write(it)


David




More information about the Python-list mailing list