email and smtplib modules

Mike Meyer mwm at mired.org
Sat Apr 9 17:42:04 EDT 2005


"mark.greenbank at gmail.com" <mark.greenbank at gmail.com> writes:

> Hi,
>
> I'm writing a small script that generates email and I've noticed that:
>
> 1) one should add the 'To' and 'CC' headers to the email message
> 2) one needs to specify the recipients in the smtplib sendmail() method
>
> Can someone explain how these are related?

Sure.

It's all to do with smtp. With smtp mail, as with paper mail, there is
an "envelope" that has addresses on it that the mail system uses to
deliver messages, and the "letter", that has addresses in it that are
displayed to the end user.

The To: and Cc: headers in the message itself are in the letter. The
end user sees those. smtp servers ignore them.

The recipients passed to the smtplib sendmail() method go on the
envelope. The smtp server will deliver to those addresses, and they
won't be shown to end users.

This design makes many things possible. Most used these days is spam
delivered to one address while apparently to another.

          <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list