通过smtplib发送的电子邮件将延迟到用户打开邮箱为止

时间:2019-02-21 10:36:18

标签: python

我正在编写一个向许多收件人发送电子邮件的脚本,但是这里的问题是某些电子邮件仅在用户打开邮箱之后才发送,并且接收时间与用户打开电子邮件的时间相同。

代码:

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()

0 个答案:

没有答案