user2814599
user2814599

Reputation: 1190

Emails sent from localhost with nodemailer are not delivered

I've set up an email sending like this:

        nodemailer = require("nodemailer");
...
            nodemailer.SMTP = {
                host: 'smtp.gmail.com', // required
                port: 465, // optional, defaults to 25 or 465
                domain: 'smtp.gmail.com', // domain used by client to identify itself to server
                authentication: 'login', // optional, false by default
                user: '1*******@gmail.com', // used only when use_authentication is true
                pass: '*******'  // used only when use_authentication is true
            }

            // send an e-mail
            nodemailer.send_mail(
                // e-mail options
                {
                    sender: '1*******@gmail.com',
                    to:'2*******@gmail.com',
                    subject:'Hello!',
                    html: '<p><b>Hi,</b> how are you doing?</p>',
                    body:'Hi, how are you doing?'
                },
                // callback function
                function(error, success){
                    console.log('Message ' + success ? 'sent' : 'failed');
                }

Callback function logs "sent" but email is never delivered. I followed this tutorial http://www.thihaz.com/?p=218

Do I have to setup smth additionally?

Upvotes: 0

Views: 5539

Answers (1)

Stefan
Stefan

Reputation: 1294

You can let nodemailer take care of the corresponding server, Gmail for example:

var smtpTransport = nodemailer.createTransport("SMTP",{
    auth: {
        user: "[email protected]", // service is detected from the username
        pass: "userpass"
    }
});

and then do:

transport.sendMail()

This should get you in the right path.

Upvotes: 2

Related Questions