mirror of
https://github.com/ihmily/DouyinLiveRecorder.git
synced 2025-12-26 05:48:32 +08:00
feat: add smtp port and smtp ssl config
This commit is contained in:
parent
73d9ee1334
commit
8c30787353
@ -41,6 +41,8 @@ bark推送铃声 =
|
||||
tgapi令牌 =
|
||||
tg聊天id(个人或者群组id) =
|
||||
smtp邮件服务器 =
|
||||
是否使用SMTP服务SSL加密(是/否) =
|
||||
SMTP邮件服务器端口 =
|
||||
邮箱登录账号 =
|
||||
发件人密码(授权码) =
|
||||
发件人邮箱 =
|
||||
|
||||
4
main.py
4
main.py
@ -312,7 +312,7 @@ def push_message(record_name: str, live_url: str, content: str) -> None:
|
||||
'钉钉': lambda: dingtalk(dingtalk_api_url, content, dingtalk_phone_num, dingtalk_is_atall),
|
||||
'邮箱': lambda: send_email(
|
||||
email_host, login_email, email_password, sender_email, sender_name,
|
||||
to_email, msg_title, content
|
||||
to_email, msg_title, content, smtp_port, open_smtp_ssl
|
||||
),
|
||||
'TG': lambda: tg_bot(tg_chat_id, tg_token, content),
|
||||
'BARK': lambda: bark(
|
||||
@ -1650,6 +1650,8 @@ while True:
|
||||
tg_token = read_config_value(config, '推送配置', 'tgapi令牌', "")
|
||||
tg_chat_id = read_config_value(config, '推送配置', 'tg聊天id(个人或者群组id)', "")
|
||||
email_host = read_config_value(config, '推送配置', 'SMTP邮件服务器', "")
|
||||
open_smtp_ssl = options.get(read_config_value(config, '推送配置', '是否使用SMTP服务SSL加密(是/否)', "是"), True)
|
||||
smtp_port = read_config_value(config, '推送配置', 'SMTP邮件服务器端口', "")
|
||||
login_email = read_config_value(config, '推送配置', '邮箱登录账号', "")
|
||||
email_password = read_config_value(config, '推送配置', '发件人密码(授权码)', "")
|
||||
sender_email = read_config_value(config, '推送配置', '发件人邮箱', "")
|
||||
|
||||
13
msg_push.py
13
msg_push.py
@ -83,7 +83,7 @@ def xizhi(url: str, title: str, content: str) -> Dict[str, Any]:
|
||||
|
||||
|
||||
def send_email(email_host: str, login_email: str, email_pass: str, sender_email: str, sender_name: str,
|
||||
to_email: str, title: str, content: str) -> Dict[str, Any]:
|
||||
to_email: str, title: str, content: str, smtp_port: str = None, open_ssl: bool = True) -> Dict[str, Any]:
|
||||
receivers = to_email.replace(',', ',').split(',') if to_email.strip() else []
|
||||
|
||||
try:
|
||||
@ -97,7 +97,12 @@ def send_email(email_host: str, login_email: str, email_pass: str, sender_email:
|
||||
t_apart = MIMEText(content, 'plain', 'utf-8')
|
||||
message.attach(t_apart)
|
||||
|
||||
smtp_obj = smtplib.SMTP_SSL(email_host, 465)
|
||||
if open_ssl:
|
||||
smtp_port = int(smtp_port) or 465
|
||||
smtp_obj = smtplib.SMTP_SSL(email_host, smtp_port)
|
||||
else:
|
||||
smtp_port = int(smtp_port) or 25
|
||||
smtp_obj = smtplib.SMTP(email_host, smtp_port)
|
||||
smtp_obj.login(login_email, email_pass)
|
||||
smtp_obj.sendmail(sender_email, receivers, message.as_string())
|
||||
return {"success": receivers, "error": []}
|
||||
@ -237,7 +242,7 @@ if __name__ == '__main__':
|
||||
# sender_name="",
|
||||
# to_email="",
|
||||
# title="",
|
||||
# content=""
|
||||
# content="",
|
||||
# )
|
||||
|
||||
bark_url = 'https://xxx.xxx.com/key/'
|
||||
@ -247,4 +252,4 @@ if __name__ == '__main__':
|
||||
api="https://ntfy.sh/xxxxx",
|
||||
title="直播推送",
|
||||
content="xxx已开播",
|
||||
)
|
||||
)
|
||||
Loading…
x
Reference in New Issue
Block a user