email and smtplib modules

M

mark.greenbank

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?

Thanks,
Mark
 
M

Mike Meyer

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
 
R

Roman Neuhauser

# (e-mail address removed) / 2005-04-09 16:42:04 -0500:
...
This design makes many things possible. Most used these days is spam
delivered to one address while apparently to another.

What about mailing lists? Quoting from your message as it arrived
here:

Return-Path: python-list-bounces+neuhauser+python-list#[email protected]
X-Original-To: neuhauser+python-list#[email protected]
From: Mike Meyer <[email protected]>
To: (e-mail address removed)

For the OP:

Return-Path: header contains the envelope sender (SMTP MAIL command)
X-Original-To: is the envelope recipient (SMTP RCPT command)

So, despite the email claiming to be sent from Mike to the list,
it's actually from the list to me.

Please take Mike's note about spam with two grains of salt, the
distinction between headers and envelope is vital to the SMTP
protocol and many services built around it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top