OuZuYu / direct-mail

send DirectMail with Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

  • 兼容 Node.js/浏览器端
  • Promise 风格
  • 支持以下 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

Attention

HtmlBodyTextBody 不能出现英文输入法的括号 (),否则签名不通过。

总之,邮件内容最好不要出现英文输入法的字符。

⬆ Back to Top

Reference

⬆ Back to Top

Contributors

Thanks goes to these wonderful people (emoji key):

levy
levy

💻 ⚠️ 📖
donhac
donhac

💻 📖 🚇

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

⬆ Back to Top

License

MIT

⬆ Back to Top

Inspiration

thanks to Mttylzq

About

send DirectMail with Node.js

License:MIT License


Languages

Language:JavaScript 86.7%Language:Shell 13.3%