Sha*_*wel 5 ssl ruby-on-rails actionmailer
我在尝试将校园的 SMTP 服务器与 Rails 5.x 应用程序一起使用时遇到问题。我收到以下错误: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: 未知协议。
这是我的配置:
config.action_mailer.smtp_settings = {
address: 'address.domain',
port: 587,
user_name: 'UNAME',
password: 'PWD',
authentication: :login,
tls: true,
enable_starttls_auto: true
}
Run Code Online (Sandbox Code Playgroud)
为了确保我使用最新的 openssl 版本,我还在 Gemfile 中要求了“openssl”,并且它安装了 openssl-2.1.2。
关于后续步骤的建议?
port: 587,
...
tls: true,
enable_starttls_auto: true
Run Code Online (Sandbox Code Playgroud)
根据文档 “:ssl/:tls - 启用 SMTP 连接以使用 SMTP/TLS(SMTPS:通过直接TLS 连接的 SMTP)”。但端口 587 不适用于直接 TLS,而是用于通过 STARTTLS 命令进行 TLS 升级。如果启用,直接 TLS 将在端口 465 上完成。
因此,您的客户端尝试使用 TLS 访问非 TLS 连接,这会导致此奇怪的错误。另请参阅我对类似问题的解释,其中发生这种情况的是 Perl 而不是 Ruby。
要解决此问题,请使用端口 465 tls(如果在服务器上启用)或使用端口 587,并依赖enable_starttls_auto它稍后升级到 TLS。
| 归档时间: |
|
| 查看次数: |
3611 次 |
| 最近记录: |