1.0.2 • Published 6 years ago
@femessage/direct-mail v1.0.2
direct-mail
阿里云 邮件推送 (DirectMail) Node.js SDK(兼容浏览器端)
Table of Contents
Feature
支持以下 API
- SingleSendMail 单一发信接口,支持发送触发和其他单个邮件
 - BatchSendMail 批量发信接口,支持通过调用模板的方式发送批量邮件
 
Install
yarn add @femessage/direct-mailExample
发送单个邮件
const directMail = require('@femessage/direct-mail')
const singleConfig = {
  AccountName: 'yourmail@mail.com',
  FromAlias: '化名',
  ToAddress: 'toaddress@mail.com',
  Subject: '标题',
  HtmlBody: '<html>内容</html>',
  AccessKeySecret: '',
  AccessKeyId: ''
}
directMail
  .SingleSendMail(singleConfig)
  .then(resp => {})
  .catch(err => {})批量发送邮件
const directMail = require('@femessage/direct-mail')
const batchConfig = {
  AccountName: 'yourmail@mail.com',
  ReceiversName: 'defaultReceivers',
  TemplateName: 'offer',
  AccessKeySecret: '',
  AccessKeyId: ''
}
directMail
  .BatchSendMail(batchConfig)
  .then(resp => {})
  .catch(err => {})dotenv
AccessKeyId、AccessKeySecret 也可以通过环境来设置。
推荐使用dotenv
#.env
ACCESS_KEY_ID=
ACCESS_KEY_SECRET=则可以在调用时,不用传 AccessKeyId、AccessKeySecret
const config = {
  AccountName: 'yourmail@mail.com',
  FromAlias: '化名',
  ToAddress: 'toaddress@mail.com',
  Subject: '标题',
  HtmlBody: '<html>内容</html>'
}
directMail
  .SingleSendMail(config)
  .then(resp => {})
  .catch(err => {})Reference
- 更多参数说明,请看aliyun official docs
 - 产品相关使用手册,请看FAQ
 
Contributors
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
License
Inspiration
thanks to Mttylzq
1.0.2
6 years ago