472,374 Members | 1,576 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,374 software developers and data experts.

subject with smtplib?

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)

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.

Jeff Sandys
Jul 18 '05 #1
1 3247
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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Van_Gogh | last post by:
Hi, I am learning how to use the smtplib module, but am having some very early problems, maybe because I don't understand it. So, am I correct that by following the example in the Python: >>>...
by: Grzegorz ¦lusarek | last post by:
Hi all. I sending email using standard python modules smtplib, email, coding email in utf but subject of message is not coded properly. In subject i use my national characters (polish) and after...
by: Roger | last post by:
I am having a problem sending email through smtp.gmail.com using smtplib. Everything works and the mail is sent and received, except quit. The following shows the problem (without bothering to...
by: zxo102 | last post by:
Hi, I am trying to use python module smtplib to send my email out on window xp (localhost). import smtplib server = smtplib.SMTP('localhost') but I got the error information as follows: ...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.