sendMessageUtil.js
788 字节
/**
* 发送短信
*/
const SMSClient = require('@alicloud/sms-sdk')
// ACCESS_KEY_ID/ACCESS_KEY_SECRET 根据实际申请的账号信息进行替换
const accessKeyId = 'yourAccessKeyId'
const secretAccessKey = 'yourAccessKeySecret'
//初始化sms_client
let smsClient = new SMSClient({accessKeyId, secretAccessKey})
function message(){
}
message.prototype.sendMessage = async(recipient, subject, html) => {
try {
let smsData = await smsClient.sendSMS({
PhoneNumbers: '15314352870',
SignName: '云通信产品',
TemplateCode: 'SMS_000000',
TemplateParam: '{"code":"12345","product":"云通信"}'
})
console.log(smsData);
} catch (error) {
throw error
}
}
module.exports = new message();