tags:

views:

79

answers:

3

Hello,

I am trying to send an email to multiple people. The code below shows what I'm trying to do. When I add 2 addresses the email does not send to the second person. The code is:

   me = '[email protected]'
   you = '[email protected], [email protected]'
   msg['Subject'] = "The Nightly Build Results"
   msg['From'] = me
   msg['To'] = you

   # Send the message via our own SMTP server
   s = smtplib.SMTP('a.a.a.a')
   s.sendmail(me, [you], msg.as_string())
   s.quit()

I have tried:

you = ['[email protected]', '[email protected]']

and

you = '[email protected]', '[email protected]'

Thanks

+2  A: 

You want this:

from email.utils import COMMASPACE
...
you = ["[email protected]", "[email protected]"]
...
msg['To'] = COMMASPACE.join(you)
...
s.sendmail(me, you, msg.as_string())
John Feminella
+3  A: 

Try

s.sendmail(me, you.split(","), msg.as_string())

If you do you = ['[email protected]', '[email protected]']

Try

msg['To'] = ",".join(you)

...

s.sendmail(me, you, msg.as_string())
S.Mark
+1  A: 

you = ('one@address', 'another@address') s.sendmail(me, you, msg.as_string())

alvherre