I can't see where i'm going wrong with this, I hope someone can spot the problem. I'd like to send an email to multiple addresses; however, it only sends it to the first email address in the list and not both. Here's the code:
import smtplib
from smtplib import SMTP
recipients = ['example1@gmail.com', 'example2@example.com']
def send_email (message, status):
fromaddr = 'from@gmail.com'
toaddrs = ", ".join(recipients)
server = SMTP('smtp.gmail.com:587')
server.ehlo()
server.starttls()
server.ehlo()
server.login('example_username', 'example_pw')
server.sendmail(fromaddr, toaddrs, 'Subject: %s\r\n%s' % (status, message))
server.quit()
send_email("message","subject")
Has anyone came across this error before?
Thank you for your time.