Writing 'intercepted' e-mail message to a mailbox

Donn Cave donn at u.washington.edu
Thu Apr 19 11:59:57 EDT 2001


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

| I am redirecting all email sent user1 at myhost.co.za to a python script,
| which
| extracts certain data from the e-mail and writes it to file.  But now I
| still want
| user1 to receive this e-mail.
|
| I read the incoming mail using
|   mailMessage = rfc822.Message(sys.stdin)
|
| How can I get the message from my variable mailMessage into user1's
| mailbox??  I can not find a method that does it.

I'm pretty sure there is no such function in the Python library, and
it's a hard one to write.  Mailbox files can use one of several different
data formats, depending on how they do things at your site, and in any
case you must carefully interlock against other software that could
accidentally try to modify the file at the same time.

But in this case I doubt you need to.  If you have a ".forward" file
that routes the mail into the Python program, then all you need to
do is change its contents from
  "|/that/path/mailread"
to
  \user1, "|/that/path/mailread"
, and the mail delivery system will deal with it.

	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list