我正在编写一个向许多收件人发送电子邮件的脚本,但是这里的问题是某些电子邮件仅在用户打开邮箱之后才发送,并且接收时间与用户打开电子邮件的时间相同。
代码:
def emailTo_sig(strTo, listDevices):
msgRoot = MIMEMultipart('related')
author = formataddr((str(Header(USER_NAME, 'utf-8')), USER_MAIL))
msgRoot['Subject'] = MAIL_TITLE
msgRoot['From'] = author
msgRoot['To'] = strTo
msgRoot.preamble = 'This is a multi-part message in MIME format.'
msgAlternative = MIMEMultipart('alternative')
msgRoot.attach(msgAlternative)
msgText = MIMEText(str(strForm.read()) + listDevices + str(strSig.read()), 'html')
msgAlternative.attach(msgText)
smtp = smtplib.SMTP()
smtp.connect(MAIL_SERVER)
smtp.login(USER_MAIL, PASSWORD)
toList = []
toList.append(strTo)
if CC == 'True':
toList.append(CC_MAIL_LIST)
smtp.sendmail(USER_MAIL, toList, msgRoot.as_string())
else:
smtp.sendmail(USER_MAIL, [strTo, USER_MAIL], msgRoot.as_string())
smtp.quit()