为什么我不能使用此脚本向多个收件人发送电子邮件?
我没有收到任何错误或退回邮件,并且第一个收件人确实收到了电子邮件。其他人都没有。
剧本:
#!/usr/bin/python
import smtplib
SMTP_SERVER = 'smtp.gmail.com'
SMTP_PORT = 587
recipient = 'email@domain.com; email2@domain.com;'
sender = 'me@gmail.com'
subject = 'the subject'
body = 'the body'
password = "password"
username = "me@gmail.com"
body = "" + body + ""
headers = ["From: " + sender,
"Subject: " + subject,
"To: " + recipient,
"MIME-Version: 1.0",
"Content-Type: text/html"]
headers = "\r\n".join(headers)
session = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
session.ehlo()
session.starttls()
session.ehlo
session.login(username, password)
session.sendmail(sender, recipient, headers + "\r\n\r\n" + body)
session.quit()