跳至内容
U-Mail邮件营销平台FAQ
用户工具
您在这里:
首页
»
smtp接口说明--使用nodejs通过smtp协议发信
smtp接口说明--使用nodejs通过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": "smtp.bestedm.org", "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" style="width:200px;height:auto">', // 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); });
smtp接口说明--使用nodejs通过smtp协议发信.txt
· 最后更改: 2017/03/22 03:52 (外部编辑)
页面工具
显示页面
回到顶部