$ npm i egg-sms --save
// {app_root}/config/plugin.js
exports.sms = {
enable: true,
package: 'egg-sms'
}
// {app_root}/config/config.default.js
exports.sms = {
client: {
accessKeyId: 'your access key',
secretAccessKey: 'your access secret'
}
}
see config/config.default.js for more detail.
detail on ali doc here
- sms.sendSMS(params)
- sms.queryDetail(params)
- sms.receiveMsg(params)
You can acquire sms instance on app
or ctx
// {app_root}/app/controller/sms.js
...
async send () {
await this.ctx.sms.sendSMS({
PhoneNumbers: '1500000000',
SignName: '云通信产品',
TemplateCode: 'SMS_000000',
TemplateParam: '{"code":"12345"}'
})
}
...
Please open an issue here.