Alibaba Cloud Email Service (direct mail) Node. js SDK (compatible with browser side)
- 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
yarn add @femessage/direct-mail
const directMail = require('@femessage/direct-mail')
const singleConfig = {
AccountName: 'yourmail@mail.com',
FromAlias: '化名',
ToAddress: 'toaddress@mail.com',
Subject: '标题',
HtmlBody: '<html>内容</html>',
AccessKeyId: process.env.ACCESS_KEY_ID,
AccessKeySecret: process.env.ACCESS_KEY_SECRET
}
directMail
.SingleSendMail(singleConfig)
.then(resp => {})
.catch(err => {})
const directMail = require('@femessage/direct-mail')
const batchConfig = {
AccountName: 'yourmail@mail.com',
ReceiversName: 'defaultReceivers',
TemplateName: 'offer',
AccessKeyId: process.env.ACCESS_KEY_ID,
AccessKeySecret: process.env.ACCESS_KEY_SECRET
}
directMail
.BatchSendMail(batchConfig)
.then(resp => {})
.catch(err => {})
AccessKeyId, AccessKeySecret can also be set via dotenv
#.env
ACCESS_KEY_ID=
ACCESS_KEY_SECRET=
// load the config
require('dotenv').config()
Then AccessKeyId and AccessKeySecret can be omitted.
const config = {
AccountName: 'yourmail@mail.com',
FromAlias: '化名',
ToAddress: 'toaddress@mail.com',
Subject: '标题',
HtmlBody: '<html>内容</html>'
}
directMail
.SingleSendMail(config)
.then(resp => {})
.catch(err => {})
HtmlBody
OrTextBody
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
- For more Parameter descriptions, please see Aliyun official docs
- Product related manual, please see FAQ
Thanks goes to these wonderful people (emoji key):
levy 💻 |
donhac 💻 📖 🚇 |
ColMugX 📖 |
This project follows the all-contributors specification. Contributions of any kind welcome!
thanks to Mttylzq