【问题标题】:self signed certificate in certificate chain error in mail邮件中的证书链错误中的自签名证书
【发布时间】:2018-11-18 17:25:04
【问题描述】:

我试着写一个简单的邮件程序。我使用了 node mailerSMTP 协议 模块。我执行了。但它显示如下错误:

邮件中证书链中的自签名证书错误

有什么问题?

var express = require('express');
var app=express();
var nodemailer = require('nodemailer');
var smtpTransport = require('nodemailer-smtp-transport');

app.get('/nodemail', function(req, res, next) {

    var transporter = nodemailer.createTransport(smtpTransport({
        service: 'Gmail',
        host: 'smtp.gmail.com',
        port: 465,
        auth: {
            user: 'demodevelopers6@gmail.com',
            pass: '***********'
        }
    }));
    var link="https://codeforgeek.com/2016/06/node-js-redis-tutorial-building-email-verification-system/";
    transporter.sendMail({
        from: "demodevelopers6@gmail.com",
        subject:"sailjstutorials" ,
        to: "vignesh.mack03@gmail.com",
        html : "Hello"+"vignesh <br> Please Click on the link to verify your email.<br><a href="+link+">Click here to verify</a>"
    }, function(error, info) {
        if (error) {
            return console.log(error);
        }
        console.log('Message %s sent: %s', info.messageId, info.response);
        console.log("Mail sent successfully");
        res.write("Mail sent successfully");
    });
});


app.listen(8086,function()
{
    console.log("port listening");
});

【问题讨论】:

标签: node.js smtp nodemailer


【解决方案1】:

我刚才也遇到了同样的问题,请尝试查看下面的链接以获得更详细的回复。

Error: self signed certificate in certificate chain Nodejs nodemailer express

使用 tls.rejectUnauthorized = false 来帮助避免该问题。

例子:

        let transporter = nodemailer.createTransport({
            service: 'gmail',
            auth: {
                user: 'myemail@gmail.com', 
                pass: 'password' 
            },
            tls: {
                rejectUnauthorized: false
            }
        });

【讨论】:

  • @PeterGrainger 您链接的帖子没有回答问题。埃里克的回答是。
  • 在使用 mail-listener2 时,我必须使用 tlsOptions: { rejectUnauthorized: false } 才能使其正常工作
猜你喜欢
  • 2019-12-16
  • 1970-01-01
  • 2012-08-24
  • 2017-12-18
  • 2015-09-08
  • 1970-01-01
  • 1970-01-01
  • 2022-06-16
  • 2019-01-23
相关资源
最近更新 更多