// 配置
const Core = require('@alicloud/pop-core');
var client = new Core({
accessKeyId: '****', // id
accessKeySecret: '***', // 密钥
endpoint: 'https://dysmsapi.aliyuncs.com',
apiVersion: '2017-05-25'
});
// 用户模板信息
var params = {
"RegionId": "cn-hangzhou",
"PhoneNumbers": emailNum, //电话号码
"SignName": "***", //名片
"TemplateCode": "***", //模板id
"TemplateParam": "{\"code\":\"" + randomNum + "\"}" //验证码 randomNum是个变量
}
// 发送
var requestOption = {
method: 'POST'
};
client.request('SendSms', params, requestOption).then((result) => {
console.log(request); //成功
}, (ex) => {
console.log(ex); //失败
})