📧Send DirectMail with Node.js
@femessage/direct-mail"">
@femessage/direct-mail"">
Alibaba Cloud Email Service (direct mail) Node. js SDK (compatible with browser side)
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
Or TextBody
cannot contain the brackets ()
of the English input method, otherwise the signature will not pass.In short, it is best not to have English input method special characters in the mail content.
⬆Back to Top
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