Python-所有日期为1970-01-01:00的电子邮件
我有个问题,我不知道原因 我用Python发送电子邮件,所有电子邮件的日期都是1970-01-01:00 代码如下:Python-所有日期为1970-01-01:00的电子邮件,python,smtplib,Python,Smtplib,我有个问题,我不知道原因 我用Python发送电子邮件,所有电子邮件的日期都是1970-01-01:00 代码如下: def send_email(self, host, port, username, password, frommail, tomail, subject, message): msg = MIMEText(message) msg['Subject'] = subject msg['From'] = frommail msg['
def send_email(self, host, port, username, password, frommail, tomail, subject, message):
msg = MIMEText(message)
msg['Subject'] = subject
msg['From'] = frommail
msg['To'] = tomail
s = smtplib.SMTP(host, port)
s.login(username, password)
s.sendmail(frommail, [tomail], msg.as_string())
s.quit()
我使用的是Ubuntu12.04,我已经检查了系统日期,一切正常。你知道这是什么原因吗
向您问好,您没有
msg['Date'] = ...
在你的代码中
试一试
用于添加发送日期。看
msg['Date'] = email.utils.formatdate(localtime=True)