我正在测试使用meteor js和nodemailer插件发送电子邮件:
meteor add mrt:meteor-nodemailer
当页面加载时,我在导航器的控制台中看到错误: 无法阅读属性' createTransport'未定义的。
那么问题是什么?
这是代码:
///////////////////////////////////////////
var nodemailer = Nodemailer; var smtpTransport = nodemailer.createTransport("SMTP",{ service: "Gmail", auth: { user: "myname@gmail.com", pass: "mypass" } }); var emailNodemailer = function() { // setup e-mail data with unicode symbols var mailOptions = { from: "Sender Name ✔ ", // sender address to: "someone@yahoo.fr", // list of receivers subject: "Hello ✔", // Subject line text: "Hello world ✔", // plaintext body html: "Hello world ✔" // html body }; // send mail with defined transport object smtpTransport.sendMail(mailOptions, function(error, response){ if(error){ console.log(error); }else{ console.log("Message sent: " + response.message); } // if you don't want to use this transport object anymore, uncomment following line //smtpTransport.close(); // shut down the connection pool, no more messages }); };
///////////////
答案 0 :(得分:0)
这对我有用import * as nodemailer from 'nodemailer';