Fw: smtplib: including a subject

Tim Roberts timr at probo.com
Sun Mar 3 19:16:29 EST 2002


"Tal Linzen" <pachy at 012.net.il> wrote:

>Hi.
>
>I couldn't figure out how to send a mail with a 
>subject. Help?

The KEY point to remember is that smtplib is used, as the name implies, to
manage SMTP.  SMTP cares nothing about the actual content of the message.
It doesn't read the headers at all; the headers and the message body are
equally irelevant to SMTP.

Here's a sample SMTP exchange:

1.   MAIL FROM: <timr at probo.com>
2.   RCPT TO: <joe at blow.com>
3.   RCPT TO: <fred at blow.com>
4.   DATA
5.   Subject: This is a subject.
6.   From:  <noone at all>
7.   To: <winnie.pooh at hundredacres.com>
8.
9.   Just checking!
10.  .

Only lines 1, 2, 3, 4 and 10 are actually SMTP.  The rest of it is just
text.  Also note that the addresses in my sample message body (lines 6 and
7) are completely unrelated to the actual sender and recipients in lines 1,
2 and 3.  What you specify to smtplib is the stuff in lines 1, 2, and 3.
You have to create the stuff in lines 5 and beyond yourself.
--
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list