📜  如何使用带有模板的节点发送邮件 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:13.743000             🧑  作者: Mango

代码示例1
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'); } });