gpt4 book ai didi

node.js - 邮件中的证书链错误中的自签名证书

转载 作者:行者123 更新时间:2023-12-04 01:33:58 26 4
gpt4 key购买 nike

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

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

enter image description here

最佳答案

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

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

关于node.js - 邮件中的证书链错误中的自签名证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50764215/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com