Skip to content

yolopunk/egg-sms

Repository files navigation

egg-sms

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Install

$ npm i egg-sms --save

Usage

// {app_root}/config/plugin.js
exports.sms = {
  enable: true,
  package: 'egg-sms'
}

Configuration

// {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.

API

detail on ali doc here

  • sms.sendSMS(params)
  • sms.queryDetail(params)
  • sms.receiveMsg(params)

Example

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"}'
    })
  }
  ...

Questions & Suggestions

Please open an issue here.

License

MIT