mirror of
https://github.com/whyour/qinglong.git
synced 2026-05-06 16:45:18 +08:00
parent
a1ae08da58
commit
1315578878
|
|
@ -91,6 +91,14 @@ export default class NotificationService {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private parseMailRecipients(value?: string) {
|
||||||
|
const recipients = (value || '')
|
||||||
|
.split(/[;;]/)
|
||||||
|
.map((item) => item.trim())
|
||||||
|
.filter(Boolean);
|
||||||
|
return recipients.length > 0 ? recipients : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
private async gotify() {
|
private async gotify() {
|
||||||
const { gotifyUrl, gotifyToken, gotifyPriority = 1 } = this.params;
|
const { gotifyUrl, gotifyToken, gotifyPriority = 1 } = this.params;
|
||||||
try {
|
try {
|
||||||
|
|
@ -592,6 +600,7 @@ export default class NotificationService {
|
||||||
|
|
||||||
private async email() {
|
private async email() {
|
||||||
const { emailPass, emailService, emailUser, emailTo } = this.params;
|
const { emailPass, emailService, emailUser, emailTo } = this.params;
|
||||||
|
const recipients = this.parseMailRecipients(emailTo) || emailUser;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const transporter = nodemailer.createTransport({
|
const transporter = nodemailer.createTransport({
|
||||||
|
|
@ -604,7 +613,7 @@ export default class NotificationService {
|
||||||
|
|
||||||
const info = await transporter.sendMail({
|
const info = await transporter.sendMail({
|
||||||
from: `"青龙快讯" <${emailUser}>`,
|
from: `"青龙快讯" <${emailUser}>`,
|
||||||
to: emailTo ? emailTo.split(';') : emailUser,
|
to: recipients,
|
||||||
subject: `${this.title}`,
|
subject: `${this.title}`,
|
||||||
html: `${this.content.replace(/\n/g, '<br/>')}`,
|
html: `${this.content.replace(/\n/g, '<br/>')}`,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -195,12 +195,14 @@ export SMTP_SERVER=""
|
||||||
## SMTP 发送邮件服务器是否使用 SSL,填写 true 或 false
|
## SMTP 发送邮件服务器是否使用 SSL,填写 true 或 false
|
||||||
export SMTP_SSL=""
|
export SMTP_SSL=""
|
||||||
|
|
||||||
## smtp_email 填写 SMTP 收发件邮箱,通知将会由自己发给自己
|
## smtp_email 填写 SMTP 发件邮箱
|
||||||
export SMTP_EMAIL=""
|
export SMTP_EMAIL=""
|
||||||
## smtp_password 填写 SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定
|
## smtp_password 填写 SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定
|
||||||
export SMTP_PASSWORD=""
|
export SMTP_PASSWORD=""
|
||||||
## smtp_name 填写 SMTP 收发件人姓名,可随意填写
|
## smtp_name 填写 SMTP 收发件人姓名,可随意填写
|
||||||
export SMTP_NAME=""
|
export SMTP_NAME=""
|
||||||
|
## smtp_email_to 填写 SMTP 收件邮箱,多个用英文;分隔,不填默认发给发件邮箱
|
||||||
|
export SMTP_EMAIL_TO=""
|
||||||
|
|
||||||
## 17. PushMe
|
## 17. PushMe
|
||||||
## 官方说明文档:https://push.i-i.me/
|
## 官方说明文档:https://push.i-i.me/
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,8 @@ const push_config = {
|
||||||
|
|
||||||
SMTP_SERVICE: '', // 邮箱服务名称,比如 126、163、Gmail、QQ 等,支持列表 https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json
|
SMTP_SERVICE: '', // 邮箱服务名称,比如 126、163、Gmail、QQ 等,支持列表 https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json
|
||||||
SMTP_EMAIL: '', // SMTP 发件邮箱
|
SMTP_EMAIL: '', // SMTP 发件邮箱
|
||||||
SMTP_TO: '', // SMTP 收件邮箱,默认通知将会发给发件邮箱
|
SMTP_TO: '', // SMTP 收件邮箱,兼容旧参数名,默认通知将会发给发件邮箱
|
||||||
|
SMTP_EMAIL_TO: '', // SMTP 收件邮箱,多个分号分隔,默认发给发件邮箱
|
||||||
SMTP_PASSWORD: '', // SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定
|
SMTP_PASSWORD: '', // SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定
|
||||||
SMTP_NAME: '', // SMTP 收发件人姓名,可随意填写
|
SMTP_NAME: '', // SMTP 收发件人姓名,可随意填写
|
||||||
|
|
||||||
|
|
@ -1051,8 +1052,14 @@ function fsBotNotify(text, desp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function smtpNotify(text, desp) {
|
async function smtpNotify(text, desp) {
|
||||||
const { SMTP_EMAIL, SMTP_TO, SMTP_PASSWORD, SMTP_SERVICE, SMTP_NAME } =
|
const {
|
||||||
push_config;
|
SMTP_EMAIL,
|
||||||
|
SMTP_TO,
|
||||||
|
SMTP_EMAIL_TO,
|
||||||
|
SMTP_PASSWORD,
|
||||||
|
SMTP_SERVICE,
|
||||||
|
SMTP_NAME,
|
||||||
|
} = push_config;
|
||||||
if (![SMTP_EMAIL, SMTP_PASSWORD].every(Boolean) || !SMTP_SERVICE) {
|
if (![SMTP_EMAIL, SMTP_PASSWORD].every(Boolean) || !SMTP_SERVICE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1068,9 +1075,20 @@ async function smtpNotify(text, desp) {
|
||||||
});
|
});
|
||||||
|
|
||||||
const addr = SMTP_NAME ? `"${SMTP_NAME}" <${SMTP_EMAIL}>` : SMTP_EMAIL;
|
const addr = SMTP_NAME ? `"${SMTP_NAME}" <${SMTP_EMAIL}>` : SMTP_EMAIL;
|
||||||
|
const recipients = [SMTP_EMAIL_TO, SMTP_TO].reduce((list, value) => {
|
||||||
|
if (!value) {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
return list.concat(
|
||||||
|
value
|
||||||
|
.split(/[;;]/)
|
||||||
|
.map((item) => item.trim())
|
||||||
|
.filter(Boolean),
|
||||||
|
);
|
||||||
|
}, []);
|
||||||
const info = await transporter.sendMail({
|
const info = await transporter.sendMail({
|
||||||
from: addr,
|
from: addr,
|
||||||
to: SMTP_TO ? SMTP_TO.split(';') : addr,
|
to: recipients.length ? recipients : SMTP_EMAIL,
|
||||||
subject: text,
|
subject: text,
|
||||||
html: `${desp.replace(/\n/g, '<br/>')}`,
|
html: `${desp.replace(/\n/g, '<br/>')}`,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,8 @@ push_config = {
|
||||||
|
|
||||||
'SMTP_SERVER': '', # SMTP 发送邮件服务器,形如 smtp.exmail.qq.com:465
|
'SMTP_SERVER': '', # SMTP 发送邮件服务器,形如 smtp.exmail.qq.com:465
|
||||||
'SMTP_SSL': 'false', # SMTP 发送邮件服务器是否使用 SSL,填写 true 或 false
|
'SMTP_SSL': 'false', # SMTP 发送邮件服务器是否使用 SSL,填写 true 或 false
|
||||||
'SMTP_EMAIL': '', # SMTP 收发件邮箱,通知将会由自己发给自己
|
'SMTP_EMAIL': '', # SMTP 发件邮箱
|
||||||
|
'SMTP_EMAIL_TO': '', # SMTP 收件邮箱,多个分号分隔,默认发给发件邮箱
|
||||||
'SMTP_PASSWORD': '', # SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定
|
'SMTP_PASSWORD': '', # SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定
|
||||||
'SMTP_NAME': '', # SMTP 收发件人姓名,可随意填写
|
'SMTP_NAME': '', # SMTP 收发件人姓名,可随意填写
|
||||||
|
|
||||||
|
|
@ -694,6 +695,10 @@ def smtp(title: str, content: str) -> None:
|
||||||
return
|
return
|
||||||
print("SMTP 邮件 服务启动")
|
print("SMTP 邮件 服务启动")
|
||||||
|
|
||||||
|
email_to = push_config.get("SMTP_EMAIL_TO") or push_config.get("SMTP_EMAIL")
|
||||||
|
email_to_list = [
|
||||||
|
item.strip() for item in re.split(r"[;;]", email_to) if item.strip()
|
||||||
|
]
|
||||||
message = MIMEText(content, "plain", "utf-8")
|
message = MIMEText(content, "plain", "utf-8")
|
||||||
message["From"] = formataddr(
|
message["From"] = formataddr(
|
||||||
(
|
(
|
||||||
|
|
@ -701,12 +706,7 @@ def smtp(title: str, content: str) -> None:
|
||||||
push_config.get("SMTP_EMAIL"),
|
push_config.get("SMTP_EMAIL"),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
message["To"] = formataddr(
|
message["To"] = ",".join(email_to_list)
|
||||||
(
|
|
||||||
Header(push_config.get("SMTP_NAME"), "utf-8").encode(),
|
|
||||||
push_config.get("SMTP_EMAIL"),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
message["Subject"] = Header(title, "utf-8")
|
message["Subject"] = Header(title, "utf-8")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -720,7 +720,7 @@ def smtp(title: str, content: str) -> None:
|
||||||
)
|
)
|
||||||
smtp_server.sendmail(
|
smtp_server.sendmail(
|
||||||
push_config.get("SMTP_EMAIL"),
|
push_config.get("SMTP_EMAIL"),
|
||||||
push_config.get("SMTP_EMAIL"),
|
email_to_list,
|
||||||
message.as_bytes(),
|
message.as_bytes(),
|
||||||
)
|
)
|
||||||
smtp_server.close()
|
smtp_server.close()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user