RE: Subject line with smtplib.sendmail()

Discussion in 'Python' started by Boudreau, Emile, Mar 20, 2007.

  1. Thanks for the reply. When I use the instruction from that list this is
    the email I receive. I'm using Outlook.


    To:
    ------------------------------
    From:
    To:
    Subject: Hello!

    This Still DOESN't Work!!!!!!!!!!!!

    It's just adding the "From" "To" "Subject" in the message itself. I want
    to have each field at the correct place and then just the msg in the
    body.

    Any Help?? Thanks


    Emile Boudreau


    -----Original Message-----
    From: python-list-bounces+emile.boudreau=
    [mailto:python-list-bounces+emile.boudreau=] On
    Behalf Of Fredrik Lundh
    Sent: Tuesday, March 20, 2007 11:08 AM
    To:
    Subject: Re: Subject line with smtplib.sendmail()

    Boudreau, Emile wrote:

    > I'm trying to send mail from my server to my machine with test
    > results. I can send the email no problem however, the email doesn't
    > contain a "recipient list" or a "subject line". I was wondering how
    > would I go about getting the information on the actual "To" and
    > "Subject" lines so that I know to whom the email was sent and the
    > subject line without opening the email?


    you have to add the headers yourself. see the example in the library
    reference, or this FAQ entry:

    http://effbot.org/pyfaq/how-do-i-send-mail-from-a-python-script

    </F>



    --
    http://mail.python.org/mailman/listinfo/python-list

    This message may contain privileged and/or confidential information. If you have received this e-mail in error or are not the intended recipient, you may not use, copy, disseminate or distribute it; do not open any attachments, delete it immediately from your system and notify the sender promptly by e-mail that you have done so. Thank you.
     
    Boudreau, Emile, Mar 20, 2007
    #1
    1. Advertising

  2. Boudreau, Emile

    Guest

    On Mar 20, 12:50 pm, "Boudreau, Emile" <>
    wrote:
    > Thanks for the reply. When I use the instruction from that list this is
    > the email I receive. I'm using Outlook.
    >
    >
    > To:
    > ------------------------------
    > From:
    > To:
    > Subject: Hello!
    >
    > This Still DOESN't Work!!!!!!!!!!!!
    >
    > It's just adding the "From" "To" "Subject" in the message itself. I want
    > to have each field at the correct place and then just the msg in the
    > body.
    >
    > Any Help?? Thanks
    >
    > Emile Boudreau
    >
    > -----Original Message-----
    > From: python-list-bounces+emile.boudreau=
    >
    > [mailto:python-list-bounces+emile.boudreau=] On
    > Behalf Of Fredrik Lundh
    > Sent: Tuesday, March 20, 2007 11:08 AM
    > To:
    > Subject: Re: Subject line with smtplib.sendmail()
    >
    > Boudreau, Emile wrote:
    >
    > > I'm trying to send mail from my server to my machine with test
    > > results. I can send the email no problem however, the email doesn't
    > > contain a "recipient list" or a "subject line". I was wondering how
    > > would I go about getting the information on the actual "To" and
    > > "Subject" lines so that I know to whom the email was sent and the
    > > subject line without opening the email?

    >
    > you have to add the headers yourself. see the example in the library
    > reference, or this FAQ entry:
    >
    > http://effbot.org/pyfaq/how-do-i-send-mail-from-a-python-script
    >
    > </F>
    >
    > --http://mail.python.org/mailman/listinfo/python-list
    >
    > This message may contain privileged and/or confidential information. If you have received this e-mail in error or are not the intended recipient, you may not use, copy, disseminate or distribute it; do not open any attachments, delete it immediately from your system and notify the sender promptly by e-mail that you have done so. Thank you.


    I'm not sure what the problem is. But here's how we do it at my place
    of work:


    import smtplib
    import string

    def sendMail(subject, body, TO = "",
    FROM=""):
    HOST = "mailserver"
    BODY = string.join((
    "From: %s" % FROM,
    "To: %s" % TO,
    "Subject: %s" % subject,
    "",
    body
    ), "\r\n")
    server = smtplib.SMTP(HOST)
    server.sendmail(FROM, [TO], BODY)
    server.quit()


    This works well for us.

    Mike
     
    , Mar 20, 2007
    #2
    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. Hank

    smtplib sendmail problems

    Hank, Feb 5, 2004, in forum: Python
    Replies:
    1
    Views:
    436
    Peter Hansen
    Feb 9, 2004
  2. sugapablo
    Replies:
    0
    Views:
    2,163
    sugapablo
    Sep 21, 2007
  3. Andrzej Adam Filip
    Replies:
    0
    Views:
    4,100
    Andrzej Adam Filip
    Mar 31, 2008
  4. Evan
    Replies:
    3
    Views:
    478
  5. Cameron Simpson
    Replies:
    0
    Views:
    104
    Cameron Simpson
    May 30, 2013
Loading...

Share This Page