u
This commit is contained in:
		
							parent
							
								
									884d4bd51a
								
							
						
					
					
						commit
						b6826662a0
					
				
							
								
								
									
										14
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								index.js
									
									
									
									
									
								
							@ -4,12 +4,12 @@ const RequestPromise = require('request-promise-native') // request-promise/-nat
 | 
				
			|||||||
const NodeMailer = require('nodemailer') // 或者 const smtpTransporter=require('nodemailer').createTransport({host:'', port:25, auth:{user:'',pass:''}})
 | 
					const NodeMailer = require('nodemailer') // 或者 const smtpTransporter=require('nodemailer').createTransport({host:'', port:25, auth:{user:'',pass:''}})
 | 
				
			||||||
let smtpTransporter = null
 | 
					let smtpTransporter = null
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let smsClient = null // 在调用时,才创建 smsClient,防止 wo.Config 还没有建立好。
 | 
					let smsClient = null // 在调用时,才创建 smsClient,防止 wo.envi 还没有建立好。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = {
 | 
					module.exports = {
 | 
				
			||||||
  sendMail: async function (option) {
 | 
					  sendMail: async function (option) {
 | 
				
			||||||
    // 或者如果smtp参数已经确定,就可以直接定义 sendMail: Bluebird.promisify(Smtp.sendMail).bind(Smtp)
 | 
					    // 或者如果smtp参数已经确定,就可以直接定义 sendMail: Bluebird.promisify(Smtp.sendMail).bind(Smtp)
 | 
				
			||||||
    smtpTransporter = smtpTransporter || NodeMailer.createTransport(wo.Config.SMTP)
 | 
					    smtpTransporter = smtpTransporter || NodeMailer.createTransport(wo.envi.SMTP)
 | 
				
			||||||
    return await util.promisify(smtpTransporter.sendMail).call(smtpTransporter, option)
 | 
					    return await util.promisify(smtpTransporter.sendMail).call(smtpTransporter, option)
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  sendSms: async function (phone, option) {
 | 
					  sendSms: async function (phone, option) {
 | 
				
			||||||
@ -29,10 +29,10 @@ module.exports = {
 | 
				
			|||||||
    var matches = phone.match(/\d+/g)
 | 
					    var matches = phone.match(/\d+/g)
 | 
				
			||||||
    var smsNumber, smsUrl
 | 
					    var smsNumber, smsUrl
 | 
				
			||||||
    if (matches[0] === '86') {
 | 
					    if (matches[0] === '86') {
 | 
				
			||||||
      smsUrl = wo.Config.SMS.dxton.urlChina
 | 
					      smsUrl = wo.envi.SMS.dxton.urlChina
 | 
				
			||||||
      smsNumber = matches[1]
 | 
					      smsNumber = matches[1]
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      smsUrl = wo.Config.SMS.dxton.urlWorld // 国际短信不需要签名、模板,可发送任意内容。
 | 
					      smsUrl = wo.envi.SMS.dxton.urlWorld // 国际短信不需要签名、模板,可发送任意内容。
 | 
				
			||||||
      smsNumber = matches[0] + matches[1]
 | 
					      smsNumber = matches[0] + matches[1]
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    //    return Bluebird.promisify(Http.get)(smsUrl+'&mobile='+smsNumber+"&content="+encodeURIComponent(msg));
 | 
					    //    return Bluebird.promisify(Http.get)(smsUrl+'&mobile='+smsNumber+"&content="+encodeURIComponent(msg));
 | 
				
			||||||
@ -74,9 +74,9 @@ module.exports = {
 | 
				
			|||||||
    smsClient =
 | 
					    smsClient =
 | 
				
			||||||
      smsClient ||
 | 
					      smsClient ||
 | 
				
			||||||
      new (require('@alicloud/sms-sdk'))({
 | 
					      new (require('@alicloud/sms-sdk'))({
 | 
				
			||||||
        // 在调用时,才创建 smsClient,防止 wo.Config 还没有建立好。
 | 
					        // 在调用时,才创建 smsClient,防止 wo.envi 还没有建立好。
 | 
				
			||||||
        accessKeyId: wo.Config.SMS.aliyun.accessKeyId,
 | 
					        accessKeyId: wo.envi.SMS.aliyun.accessKeyId,
 | 
				
			||||||
        secretAccessKey: wo.Config.SMS.aliyun.secretAccessKey,
 | 
					        secretAccessKey: wo.envi.SMS.aliyun.secretAccessKey,
 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var matches = phone.match(/\d+/g)
 | 
					    var matches = phone.match(/\d+/g)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user