Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot read property 'createTransport' of undefined

I am testing sending email with meteor js and nodemailer plugin:

meteor add mrt:meteor-nodemailer

when the page loaded, i saw error in the console of the navigator : Cannot read property 'createTransport' of undefined.

so what is the problem ?

this is the code :

///////////////////////////////////////////


var nodemailer = Nodemailer;

var smtpTransport = nodemailer.createTransport("SMTP",{
    service: "Gmail",
    auth: {
        user: "[email protected]",
        pass: "mypass"
    }
});

var emailNodemailer = function() {

    // setup e-mail data with unicode symbols
    var mailOptions = {
        from: "Sender Name ✔ ", // sender address
        to: "[email protected]", // 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
    });

};

///////////////

like image 859
user3385657 Avatar asked Nov 23 '14 00:11

user3385657


1 Answers

This worked for me import * as nodemailer from 'nodemailer';

like image 120
CameronKruse Avatar answered Oct 25 '22 21:10

CameronKruse