By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,885 Members | 1,322 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,885 IT Pros & Developers. It's quick & easy.

subject with smtplib?

P: n/a
Can you include a subject with sendmail using smtplib?

When I do this (names changed to protect the innocent):

import smtplib
toadr = "me@myisp.com"
frmadr = "my****@myhost.com"
msg = "this is an important message."
server = smtplib.SMTP('localhost')
server.sendmail(frmadr, toadr, msg)
server.quit()

I get the important message with a blank subject line.
It would be really useful to add a subject line,

sub = "important message"
server.sendmail(frmadr, toadr, msg, subject=sub)

I've looked through the documentation and see that
there is a mail_options but haven't found anything
about adding a subject.

Thanks,
Jeff Sandys
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Mon, 23 Feb 2004 23:15:17 GMT, Jeff Sandys <sa*****@juno.com>
declaimed the following in comp.lang.python:
Can you include a subject with sendmail using smtplib?

When I do this (names changed to protect the innocent):

import smtplib
toadr = "me@myisp.com"
frmadr = "my****@myhost.com"
These lines only define the handshaking done with the SMTPd.
They do not define the "to:" and "from:" headers of most email.
msg = "this is an important message."
msg should include the ENTIRE message, including the headers
that you expect the receiver to view...
Look at it this way:

"""
Date: a long time ago
From: a.*******@your.imagination
To: so*****************@a.fictitious.domain
Subject: This is junk mail

Free samples of drug of your choice
"""

is the "letter"... "From" is the sender address (corporate letterhead),
"To" is the /inside address/ (look at any book on formatting business
letters).

The "frmadr" and "toadr" are the addresses you put on the
outside of the envelope -- and don't even have to match what is on the
inside (this is how BCC: works -- the sending program puts the BCC:
addresses into "toadr" [the envelopes], and then removes the BCC: from
the letter itself so they don't show).

-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.