self signed certificate in certificate chain error in mail

房东的猫 提交于 2019-12-08 11:00:22

问题


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

what is the problem?

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


回答1:


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

Error: self signed certificate in certificate chain Nodejs nodemailer express

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

Example:

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


来源:https://stackoverflow.com/questions/50764215/self-signed-certificate-in-certificate-chain-error-in-mail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!