[Tutor] multiple "to" recipients using smtplib

Terence Lo tlo@aw.sgi.com
Tue Feb 11 16:04:03 2003


Hi there,
I have a python n00b question.  How do I specify multiple 'to' recipients
using smtplib.  I've tried the following code snippet but only the first
email recipient (user1@somewhere.com) receives the email and not the second.
I've also tried setting
toaddrs = ["user1@somehwere.com",  "user2@somere.com"] but this doesn't work
either.  Any idea what the heck I'm doing wrong?

Thanks,
TL

----------------------------------------------------------------------------
-----------------------------------
import smtplib

toaddrs = "user1@somewhere.com, user2@somewhere.com"
fromaddr = "me@me.com"
msg="This is the message"

server = smtplib.SMTP('mail.mymailserver.com')

server.sendmail(fromaddr, toaddrs, msg)
server.quit()