📅  最后修改于: 2022-03-11 15:03:13.743000             🧑  作者: Mango
var transporter = nodemailer.createTransport('smtps://user%40gmail.com:pass@smtp.gmail.com');
// create template based sender function
var sendPwdReminder = transporter.templateSender({
subject: 'Password reminder for {{username}}!',
text: 'Hello, {{username}}, Your password is: {{ password }}',
html: 'Hello, {{username}}, Your password is:\n{{ password }}'
}, {
from: 'sender@example.com',
});
// use template based sender to send a message
sendPwdReminder({
to: 'receiver@example.com'
}, {
username: 'Node Mailer',
password: '!"\'<>&some-thing'
}, function(err, info){
if(err){
console.log('Error');
}else{
console.log('Password reminder sent');
}
});