I'm trying sending emails using node mailer but I'm getting the error Error: connect ECONNREFUSED 127.0.0.1:587
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16) {
errno: -4078,
code: 'ESOCKET',
syscall: 'connect',
address: '127.0.0.1',
port: 587,
command: 'CONN'
}
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
service: 'smtp.outlook.com',
secure: false,
debug: true,
secureConnection: false,
port: 587,
auth: {
user: 'myemail@outlook.com',
pass: 'pass'
} ,
tls: {
rejectUnauthorized: true,
}
});
var mailOptions = {
from: 'myemail@outlook.com',
to: 'myemail@outlook.com',
subject: 'Sending Email using Node.js',
text: 'That was easy!'
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
}
else {
console.log('Email sent: ' + info.response);
}
});