节点邮件程序错误:连接ECONNREFUSED

时间:2017-08-04 00:54:31

标签: node.js nodemailer

我已尝试过已在网站上发布的所有解决方案,例如

1)将主机声明为smtp.gmail.com

2)安全:虚假和拒绝未注册为未注册的

3)在Gmail中允许不太安全的应用程序权限

代码段看起来像这样

 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);
}
  });

我仍然收到错误

{ 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' }

关于如何解决这个问题的任何想法?

1 个答案:

答案 0 :(得分:0)

特别是如果你在Windows上,你很可能有一个阻止请求的防病毒软件,反恶意软件或防火墙。 Windows防火墙特别擅长阻止未注册程序的SMTP输出。