且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2021-12-04 00:51:24

基本上,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.