1
0
mirror of https://github.com/6dylan6/jdpro.git synced 2025-07-17 18:04:13 +08:00
This commit is contained in:
2024
2025-05-26 21:27:37 +08:00
parent 8ff2e45f10
commit 358299e7c3
4 changed files with 52 additions and 4 deletions

View File

@@ -103,6 +103,13 @@ let IGOT_PUSH_KEY = '';
let PUSH_PLUS_TOKEN = '';
let PUSH_PLUS_USER = '';
// =======================================smtp 通知设置=======================================
let SMTP_SERVICE = ''; // 邮箱服务名称,比如 126、163、Gmail、QQ 等,支持列表 https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json
let SMTP_EMAIL = ''; // SMTP 发件邮箱
let SMTP_TO = ''; // SMTP 收件邮箱,默认通知将会发给发件邮箱
let SMTP_PASSWORD = ''; // SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定
let SMTP_NAME = ''; // SMTP 收发件人姓名,可随意填写
// ======================================= WxPusher 通知设置区域 ===========================================
// 此处填你申请的 appToken. 官方文档https://wxpusher.zjiecode.com/docs
// WP_APP_TOKEN 可在管理台查看: https://wxpusher.zjiecode.com/admin/main/app/appToken
@@ -883,7 +890,8 @@ async function sendNotify(text, desp, params = {}, author = "\n=================
ddBotNotify(text, desp), //钉钉机器人
qywxBotNotify(text, desp), //企业微信机器人
qywxamNotify(text, desp, strsummary), //企业微信应用消息推送
fsBotNotify(text, desp), //飞书机器人
fsBotNotify(text, desp), //飞书机器人
smtpNotify(text, desp), // SMTP 邮件
iGotNotify(text, desp, params), //iGot
gobotNotify(text, desp), //go-cqhttp
gotifyNotify(text, desp), //gotify
@@ -1530,7 +1538,40 @@ function qywxBotNotify(text, desp) {
}
});
}
async function smtpNotify(text, desp) {
if (![SMTP_EMAIL, SMTP_PASSWORD].every(Boolean) || !SMTP_SERVICE) {
return;
}
try {
const nodemailer = require('nodemailer');
const transporter = nodemailer.createTransport({
service: SMTP_SERVICE,
auth: {
user: SMTP_EMAIL,
pass: SMTP_PASSWORD,
},
});
const addr = SMTP_NAME ? `"${SMTP_NAME}" <${SMTP_EMAIL}>` : SMTP_EMAIL;
const info = await transporter.sendMail({
from: addr,
to: SMTP_TO ? SMTP_TO.split(';') : addr,
subject: text,
html: `${desp.replace(/\n/g, '<br/>')}`,
});
transporter.close();
if (info.messageId) {
console.log('SMTP 发送通知消息成功🎉\n');
return true;
}
console.log('SMTP 发送通知消息失败😞\n');
} catch (e) {
console.log('SMTP 发送通知消息出现异常😞\n', e);
}
}
function fsBotNotify(text, desp) {
return new Promise((resolve) => {
const options = {