尝试使用smtp-relay.gmail.com和Nodemailer发送电子邮件.错误ssl3_get_record:版本号错误 [英] Trying to send email using smtp-relay.gmail.com and Nodemailer. Error ssl3_get_record:wrong version number

查看:451
本文介绍了尝试使用smtp-relay.gmail.com和Nodemailer发送电子邮件.错误ssl3_get_record:版本号错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Trying to send email with G Suite smtp-relay using Nodemailer.

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

const result = await transporter.sendMail({
  from: `'"JOHN" <john@externaldomain.com>'`,
  to: "hello@mydomain.com",
  subject: "Hello",
  text: "Hello world!",
});

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

This is what G Suite says about using TLS: Link1 Link2

这是Nodemailer所说的:链接

This is what Nodemailer says: Link

继续

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

Basically G Suite tells me that I should use port 587 for TLS, and Nodemailer says I shouldn't.

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

Don't know if it has something to do with the ports, but this is the error I'm getting:

注意:我正在尝试在端口587上.

NOTE: I'm trying on port 587.

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

{ [Error: 13252:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:332: ] code: 'ESOCKET', command: 'CONN' }

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

If I change to port 465, I get this error:

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

'535-5.7.8 Username and Password not accepted. Learn more at\n535 5.7.8 https://support.google.com/mail/?p=BadCredentials ', responseCode: 535, command: 'AUTH PLAIN' }

我知道我的用户名和通行证是正确的.

I know my user and pass are correct.

我在做什么错了?

推荐答案

基本上,G Suite告诉我应该对TLS使用端口587,而Nodemailer说我不应该.

Basically G Suite tells me that I should use port 587 for TLS, and Nodemailer says I shouldn't.

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

Both talk about different things. The first one (G Suite) talks about SSL vs. TLS, i.e. compares various versions of the protocol. The second one (Nodemailer) talks about explicit vs. implicit TLS, i.e. explicitly upgrading a plain connection using the STARTTLS command (port 25 and 587) or establishing TLS directly after the TCP connect (port 465).

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

Thus, follow the recommendation from Nodemailer to set secure: false. If you want to enforce use of TLS, i.e. fail if STARTTLS is not supported by the mail server, then set requireTLS: true as documented.

这篇关于尝试使用smtp-relay.gmail.com和Nodemailer发送电子邮件.错误ssl3_get_record:版本号错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆