I am trying to send an email to multiple addresses. The code below shows what I'm attempting to achieve. When I add two addresses the email does not send to the second address. The code is:
me = '[email protected]'
you = '[email protected], [email protected]'
msg['Subject'] = "Some Subject"
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
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())
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())
you = ('one@address', 'another@address')
s.sendmail(me, you, msg.as_string())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With