if smtp or sms config is empty, return immediately
This commit is contained in:
parent
5fd32c86b3
commit
7b200e283a
11
messenger.js
11
messenger.js
@ -13,6 +13,10 @@ module.exports = {
|
|||||||
|
|
||||||
// 或者如果smtp参数已经确定,就可以直接定义 sendMail: Bluebird.promisify(Smtp.sendMail).bind(Smtp)
|
// 或者如果smtp参数已经确定,就可以直接定义 sendMail: Bluebird.promisify(Smtp.sendMail).bind(Smtp)
|
||||||
async sendMail (messageObject, smtp = my.envar?.SMTP || wo?.envar?.SMTP) {
|
async sendMail (messageObject, smtp = my.envar?.SMTP || wo?.envar?.SMTP) {
|
||||||
|
if (!smtp?.host) {
|
||||||
|
console.error({ _at: new Date().toJSON(), _state: 'SMTP_CONFIG_MALFORMED' }, '\n,')
|
||||||
|
return { _state: 'SMTP_CONFIG_MALFORMED' }
|
||||||
|
}
|
||||||
// messageObject: { from, to, cc, bcc, subject, text, html, sender, replyTo, inReplyTo }
|
// messageObject: { from, to, cc, bcc, subject, text, html, sender, replyTo, inReplyTo }
|
||||||
sender.smtpTransporter = sender.smtpTransporter || NodeMailer.createTransport(smtp)
|
sender.smtpTransporter = sender.smtpTransporter || NodeMailer.createTransport(smtp)
|
||||||
return await sender.smtpTransporter
|
return await sender.smtpTransporter
|
||||||
@ -38,7 +42,7 @@ module.exports = {
|
|||||||
return { _state: 'MSG_SEND_FAIL' }
|
return { _state: 'MSG_SEND_FAIL' }
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log({ _at: new Date().toJSON(), _state: 'SMS_SEND_ERROR', error }, '\n,')
|
console.error({ _at: new Date().toJSON(), _state: 'SMS_SEND_ERROR', error }, '\n,')
|
||||||
return { _state: 'SMS_SEND_ERROR' }
|
return { _state: 'SMS_SEND_ERROR' }
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -54,7 +58,10 @@ module.exports = {
|
|||||||
appid, // for 'UNICLOUD', 'TENCENT'
|
appid, // for 'UNICLOUD', 'TENCENT'
|
||||||
} = {}) {
|
} = {}) {
|
||||||
if (/^\+\d+-\d+$/.test(phone)) {
|
if (/^\+\d+-\d+$/.test(phone)) {
|
||||||
if (config.vendor === 'DXTON') {
|
if (!config?.vendor) {
|
||||||
|
console.error({ _at: new Date().toJSON(), _state: 'SMS_CONFIG_MALFORMED' }, '\n,')
|
||||||
|
return { _state: 'SMS_CONFIG_MALFORMED' }
|
||||||
|
} else if (config.vendor === 'DXTON') {
|
||||||
return await this.sendSmsDxton({ phone, config, msg })
|
return await this.sendSmsDxton({ phone, config, msg })
|
||||||
} else if (config.vendor === 'ALIYUN') {
|
} else if (config.vendor === 'ALIYUN') {
|
||||||
return await this.sendSmsAliyun({ phone, config, msgParam, msgTemplate, signName })
|
return await this.sendSmsAliyun({ phone, config, msgParam, msgTemplate, signName })
|
||||||
|
Loading…
Reference in New Issue
Block a user