fix: 邮件发送添加Date和Reply-To头
This commit is contained in:
@@ -379,6 +379,7 @@ def send_email():
|
||||
import smtplib
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from datetime import datetime
|
||||
|
||||
# SMTP配置:端口587无SSL
|
||||
smtp_host = 'mail.tphai.com'
|
||||
@@ -390,11 +391,14 @@ def send_email():
|
||||
msg['From'] = smtp_user
|
||||
msg['To'] = email_addr
|
||||
msg['Subject'] = subject
|
||||
msg['Date'] = datetime.now().strftime('%a, %d %b %Y %H:%M:%S +0800')
|
||||
msg['Reply-To'] = email_addr
|
||||
|
||||
msg.attach(MIMEText(body, 'plain', 'utf-8'))
|
||||
|
||||
# 直接连接,无SSL
|
||||
server = smtplib.SMTP(smtp_host, smtp_port)
|
||||
server.ehlo()
|
||||
server.login(smtp_user, smtp_pass)
|
||||
server.sendmail(smtp_user, email_addr, msg.as_string())
|
||||
server.quit()
|
||||
|
||||
Reference in New Issue
Block a user