561
windows
SMTP之nodejs調用示例__SMTP接口說明_郵件推送-阿裏雲
// load nodemailer as follows
// npm install nodemailer --save
var nodemailer = require('nodemailer');
// create reusable transporter object using SMTP transport
var transporter = nodemailer.createTransport({
"host": "smtpdm.aliyun.com",
"port": 25,
"secureConnection": true, // use SSL
"auth": {
"user": 'username@userdomain', // user name
"pass": 'xxxxxxx' // password
}
});
// NB! No need to recreate the transporter object. You can use
// the same transporter object for all e-mails
// setup e-mail data with unicode symbols
var mailOptions = {
from: 'NickName<username@userdomain>', // sender address mailfrom must be same with the user
to: 'x@x.com, xx@xx.com', // list of receivers
cc:'haha<xxx@xxx.com>', // copy for receivers
bcc:'haha<xxxx@xxxx.com>', // secret copy for receivers
subject: 'Hello', // Subject line
text: 'Hello world', // plaintext body
html: '<b>Hello world</b><img src="cid:01" >', // html body
attachments: [
{
filename: 'text0.txt',
content: 'hello world!'
},
{
filename: 'text1.txt',
path: './app.js'
},{
filename:'test.JPG',
path:'./Desert.jpg',
cid:'01'
}
],
};
// send mail with defined transport object
transporter.sendMail(mailOptions, function(error, info){
if(error){
return console.log(error);
}
console.log('Message sent: ' + info.response);
});
最後更新:2016-11-24 11:23:48
上一篇:
SMTP之Ruby調用示例__SMTP接口說明_郵件推送-阿裏雲
下一篇:
SMTP之GO調用示例__SMTP接口說明_郵件推送-阿裏雲
如何通過企業對公帳號打款認證完成企業實名認證__實名認證_帳號實名認證_會員賬號&實名認證-阿裏雲
阿裏雲棲大會隱藏起來的VR/AR元素有哪些?
雲資源授權__安全管理_快速入門_數據管理-阿裏雲
集群__操作指南_批量計算-阿裏雲
Mysql數據源配置__數據源配置_數據同步手冊_用戶操作指南_大數據開發套件-阿裏雲
阿裏雲歸檔存儲簡介__API使用手冊_歸檔存儲-阿裏雲
賠償說明__產品簡介_消息服務-阿裏雲
企業如何通過支付寶快速認證__實名認證_帳號實名認證_會員賬號&實名認證-阿裏雲
負載均衡性能指標__負載均衡性能常見問題_常見問題_負載均衡-阿裏雲
GetBucketAcl__關於Bucket的操作_API 參考_對象存儲 OSS-阿裏雲
相關內容
常見錯誤說明__附錄_大數據計算服務-阿裏雲
發送短信接口__API使用手冊_短信服務-阿裏雲
接口文檔__Android_安全組件教程_移動安全-阿裏雲
運營商錯誤碼(聯通)__常見問題_短信服務-阿裏雲
設置短信模板__使用手冊_短信服務-阿裏雲
OSS 權限問題及排查__常見錯誤及排除_最佳實踐_對象存儲 OSS-阿裏雲
消息通知__操作指南_批量計算-阿裏雲
設備端快速接入(MQTT)__快速開始_阿裏雲物聯網套件-阿裏雲
查詢API調用流量數據__API管理相關接口_API_API 網關-阿裏雲
使用STS訪問__JavaScript-SDK_SDK 參考_對象存儲 OSS-阿裏雲