473,657 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

smtp module - specifying multiple email recipients?

I'm using the smtp module to send emails from python.
I would like to specify several recipients of the email like follows:

msg = MIMEText(time.c time("Body text of email")

me = 'm*@sending.add ress'
you = 'r*********@som e.where,re***** ***@some.where'
msg['Subject'] = '*** Carwatch alert'
msg['From'] = me
msg['To'] = you

# Send the message via our own SMTP server, but don't include the
# envelope header.
# s = smtplib.SMTP('s mtp.ednet.co.uk ')
s = smtplib.SMTP('1 92.168.1.105')
# s.connect()
s.sendmail(me, [you], msg.as_string() )

... when I execute this code, only re********@some .where gets the email.
Is there a way to specifiy multiple addresses in the To field?

thanks
alex

Jul 18 '05 #1
2 14676

[Alex]
I would like to specify several recipients of the email like follows:

you = 'r*********@som e.where,re***** ***@some.where'
...
msg['To'] = you
...
s.sendmail(me, [you], msg.as_string() )

.. when I execute this code, only re********@some .where gets the email.


sendmail() takes a list of recipients, not a list with a single
comma-separated string in it. You need to do this:

you = ['r*********@som e.where', 're********@som e.where']
...
msg['To'] = ', '.join(you)
...
s.sendmail(me, you, msg.as_string() )

--
Richie Hindle
ri****@entrian. com
Jul 18 '05 #2
In article <10************ *@corp.supernew s.com>, Alex Hunsley wrote:
I'm using the smtp module to send emails from python. me = 'm*@sending.add ress'
you = 'r*********@som e.where,re***** ***@some.where' s.sendmail(me, [you], msg.as_string() )

.. when I execute this code, only re********@some .where gets the email.
Is there a way to specifiy multiple addresses in the To field?


The second argument to sendmail is a list, not a comma separated string.
Currently, you've specified a single address containing a comma. Your
MTA has charitably decided to deliver it to the first address, although
I expect other MTAs would just reject it. If you've got comma separated
addresses in a string, make a list using s.split(",").

--
Paul Wright | http://pobox.com/~pw201 | http://blog.noctua.org.uk/
Reply address is valid but discards mail with attachments: send plain text only
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3011
by: dmiller23462 | last post by:
So here's my problem.....I need to set up different email distributions based on which option in the following Select form has been chosen....For instance if "Putaway" is chosen it needs to email User1@here.whatever and User4@here.whatever but if "Loaded" is chosen it needs to email User2@here.whatever and User3@here.whatever, etc, etc... I'm aware that the only thing that really needs to change is the "Mail.AddAddress" line (at least...
1
2024
by: james00_c | last post by:
Greetings- I need to pass multiple email addresses to a "sendto" hidden field in a form. I need to do that because "CC" and "BCC" are not an option. One address webmaster@xyz.com would be hardcoded and another say formuser@xyz would be a user input. A sample of my form looks like: <table> <tr> <td width="100%"> <form name="fname" method="POST"
1
2127
by: eight02645999 | last post by:
hi i currently am using this email function that can send single email address def email(HOST,FROM,TO,SUBJECT,BODY,CC=None): import smtplib import string, sys body = string.join(( "From: %s" % FROM, "To: %s" % TO, "Subject: %s" % SUBJECT,
1
1518
by: TCB | last post by:
How can I separate multiple email addresses entered in a single textbox, the email addresses are separated by (,) or (;) Thanks
1
1509
by: donet programmer | last post by:
Is there a way to map multiple email addresses, for instance emailadd1@domain.com, emailadd2@domain.com.. etc to one email address emailadd@domain.com such that when an email is sent to emailadd1 or emailadd2 its received in the emailadd mailbox. I need this for testing email functionality in a .net application, has anybody done this sort of mapping.
0
2308
by: krouxsa | last post by:
Hi There people... Please help me with this query. I want to send 1 email to multiple email addresses stored in a database. Will it be possible? I'm using SQL Server 2005 and already set up the Database mail. I also tested the mail and it works fine. My problem is sending mail to multiple emails recipients stored in a Database
15
4856
pradeepjain
by: pradeepjain | last post by:
how to write javascript or is there any javascript fot validating multiple email id's ....ex xx@abc.com,yy@bbc.com Thanks, Pradeep
6
1607
by: alfasol | last post by:
I have a search module which has a search form and a php script to search. Now i have to use this search module over multiple sites . If i do that it shows path of search script on browser than the site's address .How to avoid. Please Help.
8
6001
n8kindt
by: n8kindt | last post by:
i have a function created for simple emailing (posted below). i'm new to arrays. i actually figured out how to set up the last value (Att) as an array so i could add an unlimited amount of attachments. now, i'm wondering how i could do the same for the MsgTo variable so i can add an unlimited amount of recipients. will i have to create a separate array function that will be used in the MsgTo value slot? here's my code: Option Compare Database...
0
8407
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8319
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8739
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6175
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4171
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2739
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.