-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathNotice.py
42 lines (34 loc) · 1023 Bytes
/
Notice.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 17 10:08:29 2020
@author: McLaren
"""
import Global_Config as gc
import smtplib
from email.mime.text import MIMEText
subject = "FGO脚本提示信息" # 主题
def config_check() -> bool:
if not gc.email_notice:
return False
elif gc.msg_from == "" or gc.msg_to == "" or gc.passwd == "":
print(" Need to correctly complete email config before using email notice!")
return False
else:
return True
def send_message(text="【FGO】: Detect a special drop item."):
if not config_check():
return
# 正文
msg = MIMEText(text, "plain", "utf-8")
msg["Subject"] = subject
msg["From"] = gc.msg_from
msg["To"] = gc.msg_to
try:
s = smtplib.SMTP_SSL("smtp.qq.com", 465)
s.login(gc.msg_from, gc.passwd)
s.sendmail(gc.msg_from, gc.msg_to, msg.as_string())
print("发送成功")
except s.SMTPException:
print("发送失败")
finally:
s.quit()