tobiah <[EMAIL PROTECTED]> wrote: > >In the example at: > > http://docs.python.org/lib/SMTP-example.html > >The text of the email message ends up with the From: >and To: headers in it, and yet the call to sendmail() >on the server object requires me to specify them again. > >Shouldn't smptlib just make the headers for me, given >the 'from' and 'to' addresses?
No, it shouldn't. >Perhaps this allows >me to spoof the 'from' address. Still, I might as well >just make all of the headers myself, and pass the message >as a single argument to sendmail(). E-mail consists of two distict and separate standard. The standard for how e-mail is exchanged between systems is SMTP, in RFC 2821 (originally 821). The standard for the format of a message, including headers and body, is in RFC 2822 (originally 822). SMTP needs to know who is sending, and where it going. That's what the first two parameters to smtplib.sendmail provide. The entire contents of the e-mail message, including the headers and the body, are completely opaque to SMTP. The message is nothing but "data". That's why you need to specify it twice. The first two parameters are for SMTP, and are used by the mail server (e.g., sendmail). That part is called the "envelope". The body is only used by the mail reader at the other end, which never sees the data in the SMTP exchange. Further, the SMTP protocol doesn't care about To:, Cc:, and Bcc:. There is just a list of addresses. To: and Cc: are just for the convenience of the person reading at the other end. If it didn't work that way, you couldn't do Bcc:'s. When you use a Bcc: in your mail program, the name gets added to the SmTP This is how a Bcc: is done. A Bcc: header is never included in an e-mail message. The address gets included in the envelope, but not in the headers or body. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list