Nodemailer: ECONNREFUSED
ECONNREFUSED inidcates that this is some kind of connection or firewall issue.
Can you connect to smtp.gmail.com port 465 with any other application from the same machine, for example with openssl?
openssl s_client -connect smtp.gmail.com:465
I was also using a gmail account to send the email, you might need an Application-specific password from google to allow nodemailer to work properly.
https://support.google.com/mail/answer/1173270?hl=en
Following step:
Login gmail account.
Enable pop3 in settings tabs
Enable less secure apps at: Enable less secure apps for gmail account
Display Unlock Captcha at: Display unlock Captcha
Defined email option and sending
var mailOptions = { host: 'smtp.gmail.com', port: 465, secure: true, // use SSL auth: { user: '[email protected]', pass: 'password' } } mailer = nodemailer.createTransport(mailOptions); mailer.sendMail({ .... }, function(err, response) { if (err) { console.log(err); } console.log(response); });
Hope this block code help you.
It was a firewall issue. Turns out there was nothing wrong with the code, I just didn't understand what the error message implied.