email and smtplib modules

Discussion in 'Python' started by mark.greenbank@gmail.com, Apr 9, 2005.

  1. Guest

    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
    , Apr 9, 2005
    #1
    1. Advertising

  2. Mike Meyer Guest

    "" <> 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 <> http://www.mired.org/home/mwm/
    Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
    Mike Meyer, Apr 9, 2005
    #2
    1. Advertising

  3. # / 2005-04-09 16:42:04 -0500:
    > "" <> 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?


    ...

    > 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#python.org=
    X-Original-To: neuhauser+python-list#
    From: Mike Meyer <>
    To:

    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.

    --
    How many Vietnam vets does it take to screw in a light bulb?
    You don't know, man. You don't KNOW.
    Cause you weren't THERE. http://bash.org/?255991
    Roman Neuhauser, Apr 10, 2005
    #3
  4. Guest

    Hi Mike,

    Thanks for the quick tutorial :) Quite helpful.
    , Apr 10, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    1,112
    Mike Meyer
    Jun 22, 2005
  2. Alessandro Bottoni
    Replies:
    0
    Views:
    485
    Alessandro Bottoni
    Aug 9, 2005
  3. Evan
    Replies:
    3
    Views:
    470
  4. Gabriel Genellina

    Re: smtplib send email by using gmail smtp server

    Gabriel Genellina, May 3, 2009, in forum: Python
    Replies:
    0
    Views:
    447
    Gabriel Genellina
    May 3, 2009
  5. Cameron Simpson
    Replies:
    0
    Views:
    103
    Cameron Simpson
    May 30, 2013
Loading...

Share This Page