尝试使用smtp-relay.gmail.com和Nodemailer发送电子邮件。错误ssl3_get_record:版本号错误

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

尝试使用smtp-relay和G Suite Nodemailer发送电子邮件。

const transporter = nodemailer.createTransport({
  host: "smtp-relay.gmail.com",
  port: 587,
  secure: true,
  auth: {
    user: "[email protected]",
    pass: "password"
  }
});

const result = await transporter.sendMail({
  from: `'"JOHN" <[email protected]>'`,
  to: "[email protected]",
  subject: "Hello",
  text: "Hello world!",
});

这是G Suite关于使用TLS的说法:Link1 Link2

enter image description here

enter image description here

这是Nodemailer所说的:Link

enter image description here

继续

[基本上,G Suite告诉我应该将端口587用于TLS,而Nodemailer说我不应该。

不知道是否与端口有关,但这是我得到的错误:

注意:我正在尝试端口587

{[错误:13252:错误:1408F10B:SSL例程:ssl3_get_record:版本号错误:c:\ ws \ deps \ openssl \ openssl \ ssl \ record \ ssl3_record.c:332: ]代码:“ ESOCKET”,命令:“ CONN”}

如果更改为端口465,则会出现此错误:

'535-5.7.8用户名和密码不被接受。在\ n535 5.7.8 https://support.google.com/mail/?p=BadCredentials中了解更多信息, responseCode:535, 命令:'AUTH PLAIN'}

我知道我的用户和密码正确。

我在做什么错?

email ssl tls1.2 nodemailer gsuite
1个回答
0
投票

基本上,G Suite告诉我应该将端口587用于TLS,而Nodemailer说我不应该。

双方都谈论不同的事情。第一个(G Suite)讨论SSL与TLS,即比较协议的各种版本。第二个(Nodemailer)讨论显式TLS和隐式TLS,即使用STARTTLS命令(端口25和587)显式升级普通连接,或在TCP连接之后直接建立TLS(端口465)。

因此,请按照Nodemailer的建议设置secure: false。如果要强制使用TLS,即如果邮件服务器不支持STARTTLS,则失败,然后设置requireTLS: true as documented

© www.soinside.com 2019 - 2024. All rights reserved.