[Tutor] Stdin email question
Kirk Bailey
idiot1@netzero.net
Sun May 18 01:54:02 2003
more.
Reading in 'Learning Python', I see many wise words of clarity.
you can use sys.stdin.read(), sys.stdin,readline(), or sys.stdin.readlines()
message=sys.stdin.readlines()
should definately hand you the entire message, MINUS the envlope data, which
the smtp server ate for lunch.
Now riddle me this: whyfor do you want to grok the entire thing undigested?
If you simply want to capture the message for examination, why not just feed it to a file?
To do it takes a simple alias:
aliasname:/pathtofile/filename
the file should be existant, and be writable by your Mail Transmission Agent (MTA,
frequently Sendmail). IF THE PATH HAS ANY S P A C E S IN IT, YOU MUST BRACKET IT IN
"QUOTES".
aliasname:"/path to file/filename"
Like that.
Hmmm, are you trying to write a mail filtering script??? Or what?
(this is getting intresting...)
james dean wrote:
>
> I'm trying to read an email message from stdin.
>
> I can get the email headers:
>
> headers = rfc822.Message(sys.stdin)
>
> I can get the message body:
>
> body = sys.stdin.read()
>
>
> but I can't for the life of me get the whole message headers and body in
> one go.
>
> How can I do this please.
>
> James
>
> _________________________________________________________________
> The new MSN 8: smart spam protection and 2 months FREE*
> http://join.msn.com/?page=features/junkmail
>
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
--
end
Respectfully,
Kirk D Bailey
+------------------------------------------------------------+
| Owner Howler Monkey Email: http://www.howlermonkey.net/ |
| Inventor of TinyList list server: http://www.tinylist.org/ |
| Consulting freestyle Grump: http://www.sacredelectron.org/ |
| Remember: When we referr to FREE software, we are talking |
| about FREEDOM, not $PRICE$. |
+------------------------------------------------------------+