Reading e-mail body (newbie)

Sheila King sheila at spamcop.net
Tue Mar 27 08:46:05 EST 2001


On Tue, 27 Mar 2001 14:51:08 +0200, Jacobus van der Merwe <jacobus at geo.co.za>
wrote in comp.lang.python in article
<mailman.985697556.21712.python-list at python.org>:

:I have a script to which e-mail to a certain address is relayed.
:I need to write the body of the e-mail to a file.
:I use
:
:rfc822.Message(sys.stdin)
:
:to read the e-mail, but I can't figure out how to access the body.
:It seems that rfc822 only have methods to access the headers. ????
:Any help will be appreciated.


#! /usr/bin/env python

import rfc822, sys, os

inheaders=rfc822.Message(sys.stdin, 0)

for h in inheaders.headers:
	print h,

print 
for line in sys.stdin.readlines():
	print line,
print
print
print "This message was passed through a Python script"
print "passmailthrough.py"


--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/



More information about the Python-list mailing list