我正在尝试使用以下电子邮件向多个收件人发送电子邮件,但它只发送到第一封电子邮件,知道为什么以及如何发送给多个收件人吗?
from email.mime.text import MIMEText
from smtplib import SMTP
def email (body,subject,SendToList):
msg = MIMEText("%s" % body, 'html')
msg['Content-Type'] = "text/html; charset=UTF8"
msg['Subject'] = subject
s = SMTP('localhost',25)
s.sendmail('fromuserid@company.com', SendToList,msg=msg.as_string())
def main ():
SendToList = 'userid1@company.com,userid2@company.com'
with open('email.txt', 'r') as f:
body = f.read()
subject = "test email"
email(body,subject,SendToList)
print "Done"
if __name__ == '__main__':
main()