I am having trouble sending an email to a list of recipients using an smtp.
I can send the email to the first recipient but not the rest. My recipients are in a list. I have tried turning the list into a string. As well as adding a comma or a semicolon to each email in the list but each to no avail.
My email list is formatted like this:
['[email protected]', '[email protected]']
And I am using this to send it:
from Dmail import Email
sender_email = '[email protected]'
with Email(mail_server="smtp.myserver.org", sender_email=sender_email, mail_port=25, mail_use_ssl=False,
mail_use_tls=False) as email:
email.send("Test Body", email_list, subject="test")
Any help on this appreciated. Currently, I have the email sending to myself and I can see that there are multiple recipients in the "to" column, but none of them are actually receiving the email. Using Python 3.9 Thank you.
CodePudding user response:
I was able to fix this by doing:
email_list= '; '.join(email_list)
and
email.send("Test Body", email_list.split(';'), subject="test")