fix: 端口587无SSL直接连接
This commit is contained in:
@@ -380,7 +380,7 @@ def send_email():
|
|||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from email.mime.multipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
|
|
||||||
# SMTP配置
|
# SMTP配置:端口587无SSL
|
||||||
smtp_host = 'mail.tphai.com'
|
smtp_host = 'mail.tphai.com'
|
||||||
smtp_port = 587
|
smtp_port = 587
|
||||||
smtp_user = 'favor@tphai.com'
|
smtp_user = 'favor@tphai.com'
|
||||||
@@ -393,12 +393,8 @@ def send_email():
|
|||||||
|
|
||||||
msg.attach(MIMEText(body, 'plain', 'utf-8'))
|
msg.attach(MIMEText(body, 'plain', 'utf-8'))
|
||||||
|
|
||||||
# 端口587无SSL,尝试STARTTLS,失败则用普通连接
|
# 直接连接,无SSL
|
||||||
server = smtplib.SMTP(smtp_host, smtp_port)
|
server = smtplib.SMTP(smtp_host, smtp_port)
|
||||||
try:
|
|
||||||
server.starttls()
|
|
||||||
except smtplib.SMTPNotSupportedError:
|
|
||||||
pass # 服务器不支持TLS,继续用普通连接
|
|
||||||
server.login(smtp_user, smtp_pass)
|
server.login(smtp_user, smtp_pass)
|
||||||
server.sendmail(smtp_user, email_addr, msg.as_string())
|
server.sendmail(smtp_user, email_addr, msg.as_string())
|
||||||
server.quit()
|
server.quit()
|
||||||
|
|||||||
Reference in New Issue
Block a user