Error: connect ECONNREFUSED 142.251.10.108:465 Nodemailer ej



感谢您的宝贵时间。我是用nodemailer在Gmail帐户上发送邮件的。

const nodemailer = require('nodemailer');
var ejs = require("ejs");
const viewpath = __dirname + '/template/';
var transporter = nodemailer.createTransport({
service: 'gmail',
host: 'smtp.gmail.com',
port: 465,
secure: true, // use SSL
auth: {
user: 'sample@gmail.com',
pass: 'passs'
}, 
});
ejs.renderFile(viewpath + "test.ejs", { name: req.body.first_name }, function (err, data) {
if (err) {
console.log(err);
} else {
var mainOptions = {
from: 'sample@gmail.com',  // sender address
to: 'mymail@gmail.com',   // list of receivers
subject: 'Subject',
html: data
};
transporter.sendMail(mainOptions, function (err, info) {
if (err) {
console.log(err);
} else {
console.log('Message sent: ' + info.response);
}
});
}
});

控制台出现错误

[Error: connect ECONNREFUSED 142.251.10.108:465 .在TCPConnectWrap。afterConnect [as oncomplete] (net.js:1159:16) {errno: -4078,代码:"ESOCKET",系统调用:"连接",地址:"142.251.10.108",端口:465命令:"康涅狄格州"}] [1]

可能您的ISP提供商或网络提供商阻止465目的端口,请确保您访问该端口并检查您的网络访问

→ telnet 142.251.10.108 465
Trying 142.251.10.108...
Connected to 142.251.10.108.
Escape character is '^]'.
→ telnet smtp.gmail.com 465
Trying 108.177.14.108...
Connected to smtp.gmail.com.
Escape character is '^]'.

相关内容

  • 没有找到相关文章

最新更新