[thelist] Reading emails on the fly.........

Steve Lewis slewis at macrovista.net
Tue May 21 15:05:01 CDT 2002


Chris Ditty wrote:

>Correct.  I know how to run the program when an email is received, but what
>format is the email in when the program gets it?  Also, how would I go about
>handling the information?
>
>I also forgot to mention that I am using sendmail.
>
>
Well, now that you know how to fire the script, and you know how to
access the message contents, just try outputing the message to see what
the formatting looks like.  The question of how to handle the
information is open ended.  How do you want to handle it?

Search for newlines.  These separate each line of the header from the
next.  Search for a blank line.  This marks the end of the header and
the beginning of the remainder of the message body.  Search for MIME
content demarkers.  These mark the beginning of attachments.

Strictly off the top of my head, I think RFC 821 defines SMTP, RFC 822
talks about the format of email headers, and RFCs 2045 and 2046 define
MIME extentions to 822.  You can learn absolutely everything you need to
know from these.  Sendmail, which manages your incoming SMTP service,
will deliver the email to your script exactly as SMTP recieves it.

--Steve




More information about the thelist mailing list