I've tried all solutions that have been already posted on the site like
1)Declaring host as smtp.gmail.com
2)secure:false and rejectUnauthorized as unregistered
3) Allowing less secure apps permission in Gmail
Code snippet looks like this
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
service: 'gmail',
port:'465',
secure: 'false',
auth: {
user: 'my_id',
pass: 'my_password'
},
tls: {
rejectUnauthorized: false
}
});
var mailOptions = {
from: 'myemail',
to: receiver's email,
subject: "some text",
text: "some text"
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
and i still get the error
{ Error: connect ECONNREFUSED 74.125.124.109:465
at Object.exports._errnoException (util.js:1026:11)
at exports._exceptionWithHostPort (util.js:1049:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1085:14)
code: 'ECONNECTION',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '74.125.124.109',
port: 465,
command: 'CONN' }
Any thoughts on how to solve this?