Specifying subject using smtplib
effbot at telia.com
Sun Feb 6 17:18:50 EST 2000
Jim Severino <jimsev at my-deja.com> wrote:
> In the smtplib module, the SMTP object's method "sendmail" is formatted
> like so:
> sendmail (from_addr, to_addrs, msg[, mail_options, rcpt_options])
> Can anyone tell me where you specify the message's subject?
in the message itself.
from_addr and to_addrs are commands to the
mail transport; everything that you want to go
into the message header should be explicitly put
into the message.
(the mail transport agent may rewrite some of
the headers, but don't rely on that...)
here's an example from the eff-bot guide (see
footer for more info):
# File: smtplib-example-1.py
import string, sys
HOST = "localhost"
FROM = "effbot at spam.egg"
TO = "fredrik at spam.egg"
SUBJECT = "for your information!"
BODY = "next week: how to fling an otter"
body = string.join((
"From: %s" % FROM,
"To: %s" % TO,
"Subject: %s" % SUBJECT,
server = smtplib.SMTP(HOST)
server.sendmail(FROM, [TO], body)
<!-- (the eff-bot guide to) the standard python library:
More information about the Python-list