防病毒软件阻止nodemailer-错误:证书链中的自签名证书 [英] Antivirus is blocking nodemailer - Error: self signed certificate in certificate chain

查看:70
本文介绍了防病毒软件阻止nodemailer-错误:证书链中的自签名证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用nodemailer发送电子邮件,但是我的防病毒软件阻止了nodemailer.当我关闭防病毒软件时,发送电子邮件没有问题.

I'm using nodemailer to send emails, but my antivirus block the nodemailer. When I turn off the antivirus there is no problem sending emails.

有没有可能在不禁用防病毒的情况下使用nodemailer发送电子邮件的方法?

Are there any possible way to send emails useing nodemailer without disabling antivirus?

    const transporter = nodemailer.createTransport({
        host: 'smtp.gmail.com',
        port: 465,
        secure: true,
        auth: {
            user: 'username@gmail.com',
            pass: 'password'
        }
    });

    var mailOptions = {
        from: 'username@gmail.com',
        to: "to',
        subject: 'subject',
        html: '<div></div>'
    };

    transporter.sendMail(mailOptions, function (error, info) {
        if (error) {
            console.log(error)
        } else {
            console.log('Email sent: ' + info.response);
        }
    });

错误消息->

    { Error: self signed certificate in certificate chain
       at TLSSocket.<anonymous> (_tls_wrap.js:1105:38)
       at emitNone (events.js:106:13)
       at TLSSocket.emit (events.js:208:7)
       at TLSSocket._finishInit (_tls_wrap.js:639:8)
       at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:469:38) code: 'ESOCKET', 
       command: 'CONN' }

推荐答案

在您的 transporter 设置中,尝试添加以下内容:

In your transporter settings, try adding the following:

 const transporter = nodemailer.createTransport({
    host: 'smtp.gmail.com',
    port: 465,
    secure: true,
    auth: {
        user: 'username@gmail.com',
        pass: 'password'
    },
    // === add this === //
    tls : { rejectUnauthorized: false }
});

您现在应该可以在不禁用防病毒的情况下进行发送.

You should now be able to send without disabling your antivirus.

这篇关于防病毒软件阻止nodemailer-错误:证书链中的自签名证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆