邮件中证书链错误中的自签名证书 [英] self signed certificate in certificate chain error in mail

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

问题描述

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

I tried to write a simple mail program. I used node mailer and SMTP protocol module. I executed. But it shows an error like:

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

self signed certificate in certificate chain error in mail

有什么问题?

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");
});

推荐答案

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

I had the same issue just now, try checking out the link below for a more detailed response.

错误:Nodejs 证书链中的自签名证书nodemailer 快递

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

Use tls.rejectUnauthorized = false to help avoid the issue.

示例:

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

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

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