mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 14:56:07 +08:00
修复 notify.js smtp 通知
This commit is contained in:
parent
4e66a3aff5
commit
53346a3962
|
@ -149,11 +149,8 @@ export AIBOTK_TYPE=""
|
||||||
export AIBOTK_NAME=""
|
export AIBOTK_NAME=""
|
||||||
|
|
||||||
## 14. SMTP
|
## 14. SMTP
|
||||||
## 暂时只支持在 Python 中调用 notify.py 以发送 SMTP 邮件通知
|
## 邮箱服务名称,比如126、163、Gmail、QQ等,支持列表 https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json
|
||||||
## smtp_server 填写 SMTP 发送邮件服务器,形如 smtp.exmail.qq.com:465
|
export SMTP_SERVICE=""
|
||||||
export SMTP_SERVER=""
|
|
||||||
## smtp_ssl 填写 SMTP 发送邮件服务器是否使用 SSL,内容应为 true 或 false
|
|
||||||
export SMTP_SSL="false"
|
|
||||||
## smtp_email 填写 SMTP 收发件邮箱,通知将会由自己发给自己
|
## smtp_email 填写 SMTP 收发件邮箱,通知将会由自己发给自己
|
||||||
export SMTP_EMAIL=""
|
export SMTP_EMAIL=""
|
||||||
## smtp_password 填写 SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定
|
## smtp_password 填写 SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定
|
||||||
|
|
|
@ -113,13 +113,6 @@ let IGOT_PUSH_KEY = '';
|
||||||
let PUSH_PLUS_TOKEN = '';
|
let PUSH_PLUS_TOKEN = '';
|
||||||
let PUSH_PLUS_USER = '';
|
let PUSH_PLUS_USER = '';
|
||||||
|
|
||||||
// =======================================Cool Push设置区域=======================================
|
|
||||||
// 官方文档:https://cp.xuthus.cc/docs
|
|
||||||
// QQ_SKEY: Cool Push登录授权后推送消息的调用代码Skey
|
|
||||||
// QQ_MODE: 推送模式详情请登录获取QQ_SKEY后见https://cp.xuthus.cc/feat
|
|
||||||
let QQ_SKEY = '';
|
|
||||||
let QQ_MODE = '';
|
|
||||||
|
|
||||||
// =======================================智能微秘书设置区域=======================================
|
// =======================================智能微秘书设置区域=======================================
|
||||||
// 官方文档:http://wechat.aibotk.com/docs/about
|
// 官方文档:http://wechat.aibotk.com/docs/about
|
||||||
// AIBOTK_KEY: 填写智能微秘书个人中心的apikey
|
// AIBOTK_KEY: 填写智能微秘书个人中心的apikey
|
||||||
|
@ -135,13 +128,11 @@ let AIBOTK_NAME = '';
|
||||||
let FSKEY = '';
|
let FSKEY = '';
|
||||||
|
|
||||||
// =======================================SMTP 邮件设置区域=======================================
|
// =======================================SMTP 邮件设置区域=======================================
|
||||||
// SMTP_SERVER: 填写 SMTP 发送邮件服务器,形如 smtp.exmail.qq.com:465
|
// SMTP_SERVICE: 邮箱服务名称,比如126、163、Gmail、QQ等,支持列表 https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json
|
||||||
// SMTP_SSL: 填写 SMTP 发送邮件服务器是否使用 SSL,内容应为 true 或 false
|
|
||||||
// SMTP_EMAIL: 填写 SMTP 收发件邮箱,通知将会由自己发给自己
|
// SMTP_EMAIL: 填写 SMTP 收发件邮箱,通知将会由自己发给自己
|
||||||
// SMTP_PASSWORD: 填写 SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定
|
// SMTP_PASSWORD: 填写 SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定
|
||||||
// SMTP_NAME: 填写 SMTP 收发件人姓名,可随意填写
|
// SMTP_NAME: 填写 SMTP 收发件人姓名,可随意填写
|
||||||
let SMTP_SERVER = '';
|
let SMTP_SERVICE = '';
|
||||||
let SMTP_SSL = 'false';
|
|
||||||
let SMTP_EMAIL = '';
|
let SMTP_EMAIL = '';
|
||||||
let SMTP_PASSWORD = '';
|
let SMTP_PASSWORD = '';
|
||||||
let SMTP_NAME = '';
|
let SMTP_NAME = '';
|
||||||
|
@ -306,11 +297,8 @@ if (process.env.FSKEY) {
|
||||||
FSKEY = process.env.FSKEY;
|
FSKEY = process.env.FSKEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.SMTP_SERVER) {
|
if (process.env.SMTP_SERVICE) {
|
||||||
SMTP_SERVER = process.env.SMTP_SERVER;
|
SMTP_SERVICE = process.env.SMTP_SERVICE;
|
||||||
}
|
|
||||||
if (process.env.SMTP_SSL) {
|
|
||||||
SMTP_SSL = process.env.SMTP_SSL;
|
|
||||||
}
|
}
|
||||||
if (process.env.SMTP_EMAIL) {
|
if (process.env.SMTP_EMAIL) {
|
||||||
SMTP_EMAIL = process.env.SMTP_EMAIL;
|
SMTP_EMAIL = process.env.SMTP_EMAIL;
|
||||||
|
@ -1141,31 +1129,31 @@ function fsBotNotify(text, desp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function smtpNotify(text, desp) {
|
async function smtpNotify(text, desp) {
|
||||||
if (![SMTP_SERVER, SMTP_EMAIL, SMTP_PASSWORD].every(Boolean)) {
|
if (![SMTP_EMAIL, SMTP_PASSWORD].every(Boolean) || !SMTP_SERVICE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const nodemailer = require('nodemailer');
|
const nodemailer = require('nodemailer');
|
||||||
const transporter = nodemailer.createTransport(
|
const transporter = nodemailer.createTransport({
|
||||||
`${SMTP_SSL === 'true' ? 'smtps:' : 'smtp:'}//${SMTP_SERVER}`,
|
service: SMTP_SERVICE,
|
||||||
{
|
|
||||||
auth: {
|
auth: {
|
||||||
user: SMTP_EMAIL,
|
user: SMTP_EMAIL,
|
||||||
pass: SMTP_PASSWORD,
|
pass: SMTP_PASSWORD,
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
const addr = SMTP_NAME ? `"${SMTP_NAME}" <${SMTP_EMAIL}>` : SMTP_EMAIL;
|
const addr = SMTP_NAME ? `"${SMTP_NAME}" <${SMTP_EMAIL}>` : SMTP_EMAIL;
|
||||||
const info = await transporter.sendMail({
|
const info = await transporter.sendMail({
|
||||||
from: addr,
|
from: addr,
|
||||||
to: addr,
|
to: addr,
|
||||||
subject: text,
|
subject: text,
|
||||||
text: desp,
|
html: `${desp.replace(/\n/g, '<br/>')}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!!info.messageId) {
|
transporter.close();
|
||||||
|
|
||||||
|
if (info.messageId) {
|
||||||
console.log('SMTP发送通知消息成功🎉\n');
|
console.log('SMTP发送通知消息成功🎉\n');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1311,11 +1299,9 @@ function webhookNotify(text, desp) {
|
||||||
got(formatUrl, options).then((resp) => {
|
got(formatUrl, options).then((resp) => {
|
||||||
try {
|
try {
|
||||||
if (resp.statusCode !== 200) {
|
if (resp.statusCode !== 200) {
|
||||||
console.log('自定义发送通知消息失败!!\n');
|
console.log(`自定义发送通知消息失败!!\n${resp.body}`);
|
||||||
console.log(resp.body);
|
|
||||||
} else {
|
} else {
|
||||||
console.log('自定义发送通知消息成功🎉。\n');
|
console.log(`自定义发送通知消息成功🎉。\n${resp.body}`);
|
||||||
console.log(resp.body);
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
$.logErr(e, resp);
|
$.logErr(e, resp);
|
||||||
|
|
|
@ -245,6 +245,7 @@ reload_qinglong() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$reload_target" == 'data' ]]; then
|
if [[ "$reload_target" == 'data' ]]; then
|
||||||
|
rm -rf ${dir_root}/data
|
||||||
cp -rf ${dir_tmp}/data ${dir_root}/
|
cp -rf ${dir_tmp}/data ${dir_root}/
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -377,7 +377,7 @@
|
||||||
"飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973": "Feishu group bot: https://www.feishu.cn/hc/zh-CN/articles/360024984973",
|
"飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973": "Feishu group bot: https://www.feishu.cn/hc/zh-CN/articles/360024984973",
|
||||||
"邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json": "Email service name, e.g., 126, 163, Gmail, QQ, etc. Supported list: https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json",
|
"邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json": "Email service name, e.g., 126, 163, Gmail, QQ, etc. Supported list: https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json",
|
||||||
"邮箱地址": "Email Address",
|
"邮箱地址": "Email Address",
|
||||||
"邮箱SMTP授权码": "Email SMTP Authorization Code",
|
"SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定": "The SMTP login password may also be a special passphrase, depending on the specific email service provider's instructions",
|
||||||
"PushMe的Key,https://push.i-i.me/": "PushMe key, https://push.i-i.me/",
|
"PushMe的Key,https://push.i-i.me/": "PushMe key, https://push.i-i.me/",
|
||||||
"请求方法": "Request Method",
|
"请求方法": "Request Method",
|
||||||
"请求头Content-Type": "Request Header Content-Type",
|
"请求头Content-Type": "Request Header Content-Type",
|
||||||
|
|
|
@ -377,7 +377,7 @@
|
||||||
"飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973": "飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973",
|
"飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973": "飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973",
|
||||||
"邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json": "邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json",
|
"邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json": "邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json",
|
||||||
"邮箱地址": "邮箱地址",
|
"邮箱地址": "邮箱地址",
|
||||||
"邮箱SMTP授权码": "邮箱SMTP授权码",
|
"SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定": "SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定",
|
||||||
"PushMe的Key,https://push.i-i.me/": "PushMe的Key,https://push.i-i.me/",
|
"PushMe的Key,https://push.i-i.me/": "PushMe的Key,https://push.i-i.me/",
|
||||||
"请求方法": "请求方法",
|
"请求方法": "请求方法",
|
||||||
"请求头Content-Type": "请求头Content-Type",
|
"请求头Content-Type": "请求头Content-Type",
|
||||||
|
|
|
@ -325,7 +325,7 @@ export default {
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
{ label: 'emailUser', tip: intl.get('邮箱地址'), required: true },
|
{ label: 'emailUser', tip: intl.get('邮箱地址'), required: true },
|
||||||
{ label: 'emailPass', tip: intl.get('邮箱SMTP授权码'), required: true },
|
{ label: 'emailPass', tip: intl.get('SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定'), required: true },
|
||||||
],
|
],
|
||||||
pushMe: [
|
pushMe: [
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user