用nodemailer发送邮件,提示 self signed certificate in certificate chain,不是很明白。。求大神
发布于 1 天前 作者 Yangk030208 115 次浏览 来自 问答

var nodemailer = require(“nodemailer”); // 开启一个 SMTP 连接池 var smtpTransport = nodemailer.createTransport({ host: “smtp.hrh.net.cn”, // 主机 secureConnection: false, // 使用 SSL port: 25, // SMTP 端口 auth: { user: “******”, // 账号 pass: “password” // 密码 } }); // 设置邮件内容 var mailOptions = { from: “Yangk ****@hrh.net.cn”, // 发件地址 to: "[email protected]", // 收件列表 subject: “javascript”, // 标题 html: ‘<html></html>’ };

smtpTransport.sendMail(mailOptions, function(error, response){ if(error){ console.log(error.message); }else{ console.log("Message sent: " + response); console.log(“发送完毕”); } smtpTransport.close(); // 如果没用,关闭连接池 });

报错信息:

TIM截图20171109183702.png

1 回复

可能是因为这个 smtp 服务器的是自签名的 CA 证书吧,你可以试下其他的,而且你确认是 secureConnection 而不是 secure 么?还有个小问题是 options.pool 为 true 才使用连接池

回到顶部