Nodemailer sendMail方法给出错误:连接ETIMEDOUT

时间:2019-11-20 18:01:03

标签: javascript nodemailer

我对nodemailer sendMail方法有疑问。这是代码 错误:连接ETIMEDOUT

在TCPConnectWrap.afterConnect上的[0] [完成时](net.js:1129:14){

[0]错误:-4039,

[0]代码:“ ESOCKET”,

[0]系统调用:“连接”,

[0]地址:“地址”,

[0]端口:465,

[0]命令:“ CONN”

[0]}

const sendEmail =async (to, name, type) => {
// console.log(to)
// console.log(name)
// console.log(type)
let pool = new http.Agent();
var smtpConfig = {
    agent:pool,
    host: 'smtp.gmail.com',
    port: 465,
    secure: true, // use SSL
    auth: {
        user: '********',
        pass: '*******'
    }
};
const smtpTransport = mailer.createTransport(smtpConfig)
const mail = getEmailData(to, name, type);
console.log("here");
smtpTransport.sendMail(mail, function(error, response) {
    if(error) {
        console.log(error)
    } else {
        console.log( " email sent successfully")
    }
    smtpTransport.close();
})

}

0 个答案:

没有答案