项目作者: FEMessage

项目描述 :
📧Send DirectMail with Node.js
高级语言: JavaScript
项目地址: git://github.com/FEMessage/direct-mail.git
创建时间: 2019-06-27T03:45:20Z
项目社区:https://github.com/FEMessage/direct-mail

开源协议:MIT License

下载


direct-mail

Codacy Badge
Build Status
@femessage/direct-mail"">NPM Download
@femessage/direct-mail"">NPM Version
NPM License
PRs Welcome
Automated Release Notes by gren

Alibaba Cloud Email Service (direct mail) Node. js SDK (compatible with browser side)

中文文档

Table of Contents

Feature

  • Compatible with Node.js/browser
  • Promise style
  • Support the following API
    • SingleSendMail, supports sending triggers and other single mail
    • BatchSendMail, supports sending a batch of mails by calling templates

⬆Back to Top

Install

  1. yarn add @femessage/direct-mail

⬆Back to Top

Example

Send A Single Mail

  1. const directMail = require('@femessage/direct-mail')
  2. const singleConfig = {
  3. AccountName: 'yourmail@mail.com',
  4. FromAlias: '化名',
  5. ToAddress: 'toaddress@mail.com',
  6. Subject: '标题',
  7. HtmlBody: '<html>内容</html>',
  8. AccessKeyId: process.env.ACCESS_KEY_ID,
  9. AccessKeySecret: process.env.ACCESS_KEY_SECRET
  10. }
  11. directMail
  12. .SingleSendMail(singleConfig)
  13. .then(resp => {})
  14. .catch(err => {})

Send A Batch of Mails

  1. const directMail = require('@femessage/direct-mail')
  2. const batchConfig = {
  3. AccountName: 'yourmail@mail.com',
  4. ReceiversName: 'defaultReceivers',
  5. TemplateName: 'offer',
  6. AccessKeyId: process.env.ACCESS_KEY_ID,
  7. AccessKeySecret: process.env.ACCESS_KEY_SECRET
  8. }
  9. directMail
  10. .BatchSendMail(batchConfig)
  11. .then(resp => {})
  12. .catch(err => {})

Dotenv

AccessKeyId, AccessKeySecret can also be set via dotenv

  1. #.env
  2. ACCESS_KEY_ID=
  3. ACCESS_KEY_SECRET=
  1. // load the config
  2. require('dotenv').config()

Then AccessKeyId and AccessKeySecret can be omitted.

  1. const config = {
  2. AccountName: 'yourmail@mail.com',
  3. FromAlias: '化名',
  4. ToAddress: 'toaddress@mail.com',
  5. Subject: '标题',
  6. HtmlBody: '<html>内容</html>'
  7. }
  8. directMail
  9. .SingleSendMail(config)
  10. .then(resp => {})
  11. .catch(err => {})

⬆Back to Top

Attention

  • HtmlBody Or TextBody cannot contain the brackets () of the English input method, otherwise the signature will not pass.
  • Please only type your link by text when you need hyperlink, DON’T USE “ADD LINK” TOOL.

In short, it is best not to have English input method special characters in the mail content.
⬆Back to Top

Reference

⬆Back to Top

Contributors

Thanks goes to these wonderful people (emoji key):







levy
levy

💻 ⚠️ 📖
donhac
donhac

💻 📖 🚇
ColMugX
ColMugX

📖

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

License

MIT

⬆ Back to Top

Inspiration

thanks to Mttylzq