nodemailer 证书链中的自签名证书错误

问题描述 投票:0回答:1

我的 Gmail 帐户也获得了 lesssecureapps 状态

const transporter = nodemailer.createTransport({
      service: 'gmail',
      auth: {
        user: worker_email,
        pass: worker_pass
      }
})

当我尝试时

transporter.sendEmail(options)

我收到一个错误:

Error: self signed certificate in certificate chain
at TLSSocket.onConnectSecure (_tls_wrap.js:1321:34)
at TLSSocket.emit (events.js:223:5)
at TLSSocket._finishInit (_tls_wrap.js:794:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:608:12) {
  code: 'ESOCKET',
  command: 'CONN'
}
node.js email nodemailer
1个回答
1
投票

请参阅此简短答案:https://stackoverflow.com/a/64913747/5172977

基本上,这可能与您的交通设置有关。

这里是使用 Ethereal.email

的开发环境示例
const transporter = nodemailer.createTransport({
    host: 'smtp.ethereal.email',
    port: 587,
    auth: {
        user: '[email protected]',
        pass: 'password'
    },
    // === add this === //
    tls : { rejectUnauthorized: false }
});
© www.soinside.com 2019 - 2024. All rights reserved.