我想湯姆使用nodemailer我的應用程序發送電子郵件,我的代碼看起來是這樣的:錯誤:主機名/ IP不匹配證書的altnames Node.js的
var smtpTransport = nodemailer.createTransport(smtpTransport({
pool: true,
host: 'smtp.myemailserver.com',
port: 587,
auth: {
user: '[email protected]',
pass: '******'
}
}));
var mailOptions = {
from: '[email protected]',
to: '[email protected]',
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選項的日誌。 – Francesco
[發送電子郵件與nodemailer](https://stackoverflow.com/questions/29099582/sending-emails-with-nodemailer) –