gpt4 book ai didi

nodemailer - 错误 : Hostname/IP doesn't match certificate's altnames node. js

转载 作者:行者123 更新时间:2023-12-04 23:39:03 28 4
gpt4 key购买 nike

我想使用 nodemailer 从我的应用程序发送电子邮件,我的代码如下所示:

var smtpTransport = nodemailer.createTransport(smtpTransport({
pool: true,
host: 'smtp.myemailserver.com',
port: 587,
auth: {
user: 'user@myDomain.com',
pass: '******'
}
}));
var mailOptions = {
from: 'user@myDomain.com',
to: 'user2@gmail.com',
subject: 'test ',
text: 'Hello world ',
html: '<b>Hello world </b>'
};

smtpTransport.sendMail(mailOptions, function(error, info){
if(error){
console.log(error);
}else{
console.log('Message sent: ' + info.response);
}
});

但我得到了我无法弄清楚的错误:
 [Error: Hostname/IP doesn't match certificate's altnames: "Host: smtp.myemailserver.com. is not in the cert's altnames: DNS:secure.emailsrvr.com, DNS:www.secure.myemailserver.com"]
reason: 'Host: smtp.myemailserverr.com. is not in the cert\'s altnames: DNS:secure.myemailserver.com, DNS:www.myemailserver.com',
host: 'smtp.myemailserver.com.',
cert:
{ subject: { OU: [Object], CN: 'secure.myemailserver.com' },
issuer:
{ C: 'GB',
ST: 'Greater Manchester',
L: 'Salford',
O: 'COMODO CA Limited',
CN: 'COMODO RSA Domain Validation Secure Server CA' },
subjectaltname: 'DNS:secure.emailsrvr.com, DNS:www.secure.myemailserver.com',
infoAccess: { 'CA Issuers - URI': [Object], 'OCSP - URI': [Object] }

我试着添加
tls { 
rejectUnauthorized: false
}

到电子邮件选项,但这会导致我的电子邮件被屏蔽,所以请帮忙

最佳答案

不确定您是否像您的问题一样在代码中遗漏了冒号,但它应该是:

tls: { 
rejectUnauthorized: false
}

根据我的经验,这就是解决证书名称不匹配所需的全部内容。整个传输选项应如下所示:
var smtpTransport = nodemailer.createTransport(smtpTransport({
pool: true,
host: 'smtp.myemailserver.com',
port: 587,
auth: {
user: 'user@myDomain.com',
pass: '******'
},
tls: {
rejectUnauthorized: false
}

还要记住,这会让你 vulnerable to MITM attacks on SSL .

关于nodemailer - 错误 : Hostname/IP doesn't match certificate's altnames node. js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43472705/

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