Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to add multiple receivers in Python SMTPlib?

Tags:

python

smtplib

I was wondering. Is there any way to add multiple receivers in Python on its default SMTPlib?

Like (subject and content set already, smtp server gmail.):

python sendmail.py [email protected] [email protected] [email protected] ...

Thanks

like image 728
brc.sw Avatar asked Jan 04 '12 15:01

brc.sw


1 Answers

Tested before posting!

import smtplib
from email.mime.text import MIMEText

s = smtplib.SMTP('smtp.uk.xensource.com')
s.set_debuglevel(1)
msg = MIMEText("""body""")
sender = '[email protected]'
recipients = ['[email protected]', '[email protected]']
msg['Subject'] = "subject line"
msg['From'] = sender
msg['To'] = ", ".join(recipients)
s.sendmail(msg.get('From'), recipients, msg.as_string())
like image 61
sorin Avatar answered Sep 21 '22 12:09

sorin