Merge pull request #4 from PeanutMelonSeedBigAlmond/main

feat: 允许自定义发送邮件 smtp 服务器
This commit is contained in:
多玩幻灵qwq 2023-02-18 18:04:51 +08:00 committed by GitHub
commit 3bc0ff396d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 4 deletions

@ -11,7 +11,9 @@
"mailConfig": { "mailConfig": {
"user":"", "user":"",
"pass":"", "pass":"",
"mailto":"" "mailto":"",
"smtpServer":"",
"smtpPort":""
} }
} }
``` ```
@ -20,6 +22,21 @@
>> user 发送方邮箱<br> >> user 发送方邮箱<br>
>> pass 有授权码的填授权码,没有的填密码,填了密码报错了找授权码<br> >> pass 有授权码的填授权码,没有的填密码,填了密码报错了找授权码<br>
>> mailto 接收方邮箱 >> mailto 接收方邮箱
<br>
>> smtpServer 发送邮件时使用的 smtp 服务器地址
<br>
>> smtpPort smtp 服务器端口
对于常用的邮件而言,配置列举如下
|服务|server|port|
|:-:|:----:|:---:|
|QQ 邮箱|smtp.qq.com|465/587|
|网易邮箱|smtp.163.com|465|
|...|...|...|
其余邮箱服务的配置可以在对应服务商的帮助文档中找到
### 用户配置 ### 用户配置
先放一个配置模板 先放一个配置模板
``` ```

@ -3,6 +3,8 @@
"mailConfig": { "mailConfig": {
"user":"", "user":"",
"pass":"", "pass":"",
"mailto":"" "mailto":"",
"smtpServer":"",
"smtpPort":""
} }
} }

@ -31,8 +31,8 @@ log.info("获取成功")
if (globalConfig.sendMail == true) { if (globalConfig.sendMail == true) {
log.info("组装邮件发射器") log.info("组装邮件发射器")
var transporter = nodemailer.createTransport({ var transporter = nodemailer.createTransport({
host: 'smtp.163.com', host: globalConfig.mailConfig.smtpServer,
port: 465, port: globalConfig.mailConfig.smtpPort,
secure: true, secure: true,
auth: { auth: {
user: globalConfig.mailConfig.user, user: globalConfig.mailConfig.user,