@femessage/direct-mail
v1.0.2
Published
send Aliyun DirectMail with Node.js
Downloads
12
Readme
direct-mail
阿里云 邮件推送 (DirectMail) Node.js SDK(兼容浏览器端)
Table of Contents
Feature
支持以下 API
- SingleSendMail 单一发信接口,支持发送触发和其他单个邮件
- BatchSendMail 批量发信接口,支持通过调用模板的方式发送批量邮件
Install
yarn add @femessage/direct-mail
Example
发送单个邮件
const directMail = require('@femessage/direct-mail')
const singleConfig = {
AccountName: '[email protected]',
FromAlias: '化名',
ToAddress: '[email protected]',
Subject: '标题',
HtmlBody: '<html>内容</html>',
AccessKeySecret: '',
AccessKeyId: ''
}
directMail
.SingleSendMail(singleConfig)
.then(resp => {})
.catch(err => {})
批量发送邮件
const directMail = require('@femessage/direct-mail')
const batchConfig = {
AccountName: '[email protected]',
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: '[email protected]',
FromAlias: '化名',
ToAddress: '[email protected]',
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