RE: Subject line with smtplib.sendmail()

B

Boudreau, Emile

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

(e-mail address removed)
To:
------------------------------
From: (e-mail address removed)
To: (e-mail address removed)
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: [email protected]
[mailto:p[email protected]] On
Behalf Of Fredrik Lundh
Sent: Tuesday, March 20, 2007 11:08 AM
To: (e-mail address removed)
Subject: Re: Subject line with smtplib.sendmail()

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>
 
K

kyosohma

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

(e-mail address removed)
To:
------------------------------
From: (e-mail address removed)
To: (e-mail address removed)
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: [email protected]

[mailto:p[email protected]] On
Behalf Of Fredrik Lundh
Sent: Tuesday, March 20, 2007 11:08 AM
To: (e-mail address removed)
Subject: Re: Subject line with smtplib.sendmail()

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 = "(e-mail address removed)",
FROM="(e-mail address removed)"):
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
 

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

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,814
Latest member
SpicetreeDigital

Latest Threads

Top