1.0.2 • Published 5 years ago

@femessage/direct-mail v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

direct-mail

Build Status NPM Download NPM Version NPM License PRs Welcome Automated Release Notes by gren

阿里云 邮件推送 (DirectMail) Node.js SDK(兼容浏览器端)

Table of Contents

Feature

支持以下 API

  • SingleSendMail 单一发信接口,支持发送触发和其他单个邮件
  • BatchSendMail 批量发信接口,支持通过调用模板的方式发送批量邮件

⬆ Back to Top

Install

yarn add @femessage/direct-mail

⬆ Back to Top

Example

发送单个邮件

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 => {})

⬆ Back to Top

Reference

⬆ Back to Top

Contributors

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

⬆ Back to Top

License

MIT

⬆ Back to Top

Inspiration

thanks to Mttylzq

1.0.2

5 years ago