gpt4 book ai didi

ruby-on-rails - 如何设置 ActionMailer 使用 TLS 连接所需的 SSL 协议(protocol)?

转载 作者:太空宇宙 更新时间:2023-11-03 13:56:54 25 4
gpt4 key购买 nike

我在尝试将校园的 SMTP 服务器与我的 Rails 5.x 应用程序一起使用时遇到问题。我收到以下错误:SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol。

这是我的配置:

config.action_mailer.smtp_settings = {
address: 'address.domain',
port: 587,
user_name: 'UNAME',
password: 'PWD',
authentication: :login,
tls: true,
enable_starttls_auto: true
}

为确保我使用的是最新的 openssl 版本,我还在我的 Gemfile 中要求“openssl”,并且它安装了 openssl-2.1.2。

关于后续步骤的建议?

最佳答案

port:                 587,
...
tls: true,
enable_starttls_auto: true

根据 the documentation “:ssl/:tls - 启用 SMTP 连接以使用 SMTP/TLS(SMTPS:通过直接 TLS 连接的 SMTP)”。但端口 587 不是用于直接 TLS,而是用于通过 STARTTLS 命令进行 TLS 升级。如果启用,直接 TLS 将在端口 465 上完成。

因此,您的客户端尝试使用 TLS 访问非 TLS 连接,这导致了这个奇怪的错误。另见 my explanation on a similar question这发生在 Perl 而不是 Ruby 上。

要解决此问题,请将端口 465 与 tls(如果在服务器上启用)一起使用,或者使用端口 587 并依赖于稍后升级到的 enable_starttls_auto TLS。

关于ruby-on-rails - 如何设置 ActionMailer 使用 TLS 连接所需的 SSL 协议(protocol)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59687194/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com