Sending email via Node.js using nodemailer is not working

The answer is in the message from google.

For the second part of the problem, and in response to

I’m actually simply following the steps from the nodemailer github page so there are no errors in my code

I will refer you to the nodemailer github page, and this piece of code :

var transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
    user: '[email protected]',
    pass: 'userpass'
}
});

It differs slightly from your code, in the fact that you have : nodemailer.createTransport("SMTP".
Remove the SMTP parameter and it works (just tested). Also, why encapsulating it in a http server? the following works :

var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
    service: 'Gmail',
    auth: {
        user: 'xxx',
        pass: 'xxx'
    }
});

console.log('created');
transporter.sendMail({
from: '[email protected]',
  to: '[email protected]',
  subject: 'hello world!',
  text: 'hello world!'
});

Leave a Comment