比如邮件的HTML里要加上用户名 怎么样能够像使用模板引擎比如ejs那样使内容可以变量化
nodemailer示例
var nodemailer = require('nodemailer');
// create reusable transporter object using SMTP transport
var transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: 'gmail.user[@gmail](/user/gmail).com',
pass: 'userpass'
}
});
// 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: 'Fred Foo ✔ <foo[@blurdybloop](/user/blurdybloop).com>', // sender address
to: 'bar[@blurdybloop](/user/blurdybloop).com, baz[@blurdybloop](/user/blurdybloop).com', // list of receivers
subject: 'Hello ✔', // Subject line
html: '<b>Hello world ✔</b>' // html body
};
// send mail with defined transport object
transporter.sendMail(mailOptions, function(error, info){
if(error){
console.log(error);
}else{
console.log('Message sent: ' + info.response);
}
});