我正在尝试将变量to
(具有电子邮件 ID)附加到并将msg["To"]
电子邮件发送到此列表。没有错误或任何东西,但没有发送电子邮件。一旦我to
从中删除变量msg["To"]
,电子邮件就会成功发送。我哪里错了?
def email (body,subject,to):
msg = MIMEText("%s" % body)
msg["Content-Type"] = "text/html"
msg["From"] = "service@company.com"
msg["To"] = to + "username@company.com"
msg["Subject"] = '%s' % subject
p = Popen(["/usr/sbin/sendmail", "-t"], stdin=PIPE)
p.communicate(msg.as_string())