473,473 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

Similar topics

3
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: >>>...
1
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...
0
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...
5
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: ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.