增加Email配置端口选项

pull/467/head
疯魔 2019-11-08 13:20:20 +08:00
parent 04a4a2604f
commit b53d02d5a8
2 changed files with 7 additions and 4 deletions

View File

@ -78,6 +78,7 @@ HTTP_TYPE = "http"
# username: "xxxxx"
# password: "授权码"
# host: "smtp.qq.com"
# port: 25
EMAIL_CONF = {
"IS_MAIL": True,
"email": "",
@ -85,6 +86,7 @@ EMAIL_CONF = {
"username": "",
"password": "",
"host": "smtp.qq.com",
"port": 25
}
# 是否开启 server酱 微信提醒, 使用前需要前往 http://sc.ftqq.com/3.version 扫码绑定获取 SECRET 并关注获得抢票结果通知的公众号

View File

@ -21,6 +21,7 @@ def sendEmail(msg):
username = TickerConfig.EMAIL_CONF["username"]
password = TickerConfig.EMAIL_CONF["password"]
host = TickerConfig.EMAIL_CONF["host"]
port = TickerConfig.EMAIL_CONF["port"]
s = "{0}".format(msg)
msg = MIMEText(s, 'plain', 'utf-8') # 中文需参数utf-8单字节字符不需要
@ -29,12 +30,12 @@ def sendEmail(msg):
msg['To'] = receiver
try:
smtp = smtplib.SMTP_SSL(host)
smtp.connect(host)
smtp = smtplib.SMTP_SSL(host, port)
smtp.connect(host, port)
except socket.error:
smtp = smtplib.SMTP()
smtp.connect(host)
smtp.connect(host)
smtp.connect(host, port)
smtp.connect(host, port)
smtp.login(username, password)
smtp.sendmail(sender, receiver.split(","), msg.as_string())
smtp.quit()