hi
i have email code:
def email(HOST,FROM,TO,SUBJECT,BODY):
import smtplib
import string, sys
body = string.join((
"From: %s" % FROM,
"To: %s" % TO,
"Subject: %s" % SUBJECT,
"",
BODY), "\r\n")
print body
server = smtplib.SMTP(HOST)
server.sendmail(FROM, [TO],body)
server.quit()
is there a way to include CC list for the smtplib module?
thanks 5 6276
On 21 Oct 2005 02:34:40 -0700, ei***********@yahoo.com
<ei***********@yahoo.com> def email(HOST,FROM,TO,CC,SUBJECT,BODY): import smtplib import string, sys
body = string.join(( "From: %s" % FROM, "To: %s" % TO, "CC: %s % CC, "Subject: %s" % SUBJECT, "", BODY), "\r\n")
print body
server = smtplib.SMTP(HOST) server.sendmail(FROM, [TO]+[CC],body) server.quit()
Tim Williams (gmail) wrote: On 21 Oct 2005 02:34:40 -0700, ei***********@yahoo.com <ei***********@yahoo.com>
def email(HOST,FROM,TO,CC,SUBJECT,BODY): import smtplib import string, sys
body = string.join(( "From: %s" % FROM, "To: %s" % TO, "CC: %s % CC, "Subject: %s" % SUBJECT, "", BODY), "\r\n")
print body
server = smtplib.SMTP(HOST) server.sendmail(FROM, [TO]+[CC],body) server.quit()
Assuming that TO and CC are single addresses it would be saner to use:
server.sendmail(FROM, [TO, CC], body)
- in other words, use a two-element list rather than creating it by
concatenating two one-element lists!
Note that as far as the SMTP protocol is concerned it's the list of
recipients that gets actions, not the headers in the message.
stating-the-obvious-ly y'rs - steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/
Tim Williams (gmail) wrote: On 21 Oct 2005 02:34:40 -0700, ei***********@yahoo.com <ei***********@yahoo.com>
def email(HOST,FROM,TO,CC,SUBJECT,BODY): import smtplib import string, sys
body = string.join(( "From: %s" % FROM, "To: %s" % TO, "CC: %s % CC, "Subject: %s" % SUBJECT, "", BODY), "\r\n")
print body
server = smtplib.SMTP(HOST) server.sendmail(FROM, [TO]+[CC],body) server.quit()
Assuming that TO and CC are single addresses it would be saner to use:
server.sendmail(FROM, [TO, CC], body)
- in other words, use a two-element list rather than creating it by
concatenating two one-element lists!
Note that as far as the SMTP protocol is concerned it's the list of
recipients that gets actions, not the headers in the message.
stating-the-obvious-ly y'rs - steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/
On 21/10/05, Steve Holden <st***@holdenweb.com> wrote: Assuming that TO and CC are single addresses it would be saner to use:
:)
Assuming that the envelope TOs (inc CCs) are the same as the
Header-TOs and Header-CCs
Actually, I think this would be safer !
def email(HOST,FROM,TO,CC, RECIPS, SUBJECT,BODY):
...
...
...
server.sendmail(FROM,RECIPS,body)
RECIPS = list of SMTP recipients
TO & CC = Text representation of some/all/none of the SMTP recipients
and/or other text
RECIPS should be either a single address as a string *or* a list
containing 1 or more addresses
Tim Williams (gmail) wrote: On 21 Oct 2005 02:34:40 -0700, ei***********@yahoo.com <ei***********@yahoo.com> def email(HOST,FROM,TO,CC,SUBJECT,BODY): import smtplib import string, sys
body = string.join(( "From: %s" % FROM, "To: %s" % TO, "CC: %s % CC, "Subject: %s" % SUBJECT, "", BODY), "\r\n")
print body
server = smtplib.SMTP(HOST) server.sendmail(FROM, [TO]+[CC],body) server.quit() This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bill |
last post by:
I am trying to have the capability to email attachments. Specifically
I want to be able to email a specific attachment that I name that may
be a PDF document, text doc, etc. I already have a...
|
by: stewart.midwinter |
last post by:
I'm having problem with a script that used to work under Win2k but is
now broken after an install of WinXP Pro. I can no longer connect to a
local mail server. Has anyone else seen this? If so,...
|
by: Tim Williams |
last post by:
I have a working SMTP client that I need to add TLS capability to, I
absolutely need the client to timeout within a specified time, but when I
use the sock.timeout() line it freezes the reading...
|
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: Kun |
last post by:
i have the following code:
----------------------------------
import smtplib
from email.MIMEText import MIMEText
fp = open('confirmation.txt', 'rb')
msg = MIMEText(fp.read())
From =...
|
by: 3KWA |
last post by:
Hi all,
I tried to send a small mailing list using python today (2036 emails).
For that purpose I looked in the doc for some code examples (I had
never done it before). And I ended up writing...
|
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: Hunter |
last post by:
I am writing a script that needs to send some emails. And I've used
smtplib in the past and it is pretty easy. But I thought, gee it
would be easier if I could just call it as a function, passing...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |