我找不到此错误的解决方案,我正在本地运行,我已经检查了是否有使用端口的服务,但没有
{ Error: connect ECONNREFUSED 127.0.0.1:465
at Object.exports._errnoException (util.js:1050:11)
at exports._exceptionWithHostPort (util.js:1073:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1093:14)
code: 'ECONNECTION',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 465,
command: 'CONN' }
这里是我的设置
var transporter = nodemailer.createTransport({
service: 'smtp.gmail.com',
port: 465,
auth: {
user: process.env.EMAIL,
pass: process.env.PWD
}
});
同时运行openssl s_client -starttls smtp -crlf -connect smpt.gmail.com:465
不会同时在465和587上返回任何内容
答案 0 :(得分:0)
u在服务上添加了主机... 试试这个
var nodemailer = require('nodemailer');
var smtpTransport = require('nodemailer-smtp-transport'); // this is important
var transporter = nodemailer.createTransport(smtpTransport({
service: 'gmail',
host: 'smtp.gmail.com',
auth: {
user: 'somerealemail@gmail.com',
pass: 'realpasswordforaboveaccount'
}
}));
var mailOptions = {
from: 'somerealemail@gmail.com',
to: 'friendsgmailacc@gmail.com',
subject: 'Sending Email using Node.js[nodemailer]',
text: 'That was easy!'
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
然后根据需要通过单击此link
启用“ lesssecureapps”