473,890 Members | 1,525 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')
# 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?


Jul 18 '05 #1
2 14691

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

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...
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"
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,
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
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.
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
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
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.
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...
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...
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,...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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...
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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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.