5
votes

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
    });

};

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

1
Did you make any progress with this one? I'm having the same issue.Kyle Bachan
Dear @user3385657, Could you please check whether you have imported nodemailer using require like below? var nodemailer = require('nodemailer');Kishore Konangi
have same issue, smth is brokenSuperUberDuper

1 Answers

5
votes

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