防病毒软件阻止nodemailer

防病毒软件阻止nodemailer

本文介绍了防病毒软件阻止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: '[email protected]',
            pass: 'password'
        }
    });

    var mailOptions = {
        from: '[email protected]',
        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: '[email protected]',
        pass: 'password'
    },
    // === add this === //
    tls : { rejectUnauthorized: false }
});

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

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

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

08-27 06:02