【发布时间】:2020-06-26 09:41:09
【问题描述】:
我刚刚安装了一个 Ubuntu 20.04 服务器并且我已经安装了 redmine,但是启用了 ssl 的邮件发送不起作用。
所以我开始了一些使用 ruby 发送电子邮件的测试。
我看到了一种发送邮件in this post 的方法,所以我尝试用脚本和相关的mailer/daily_email.text.erb 做同样的事情:
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.logger = Logger.new (STDOUT)
ActionMailer::Base.logger.level = 记录器::DEBUG
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "smtps.aruba.it",
:端口=> 465,
:domain => "mydomain.it",
:authentication => :login,
:user_name => "redmine@mydomain.it",
:password => "我的密码",
:enable_starttls_auto => 真,
:ssl => 真
}
ActionMailer::Base.view_paths= File.dirname(__FILE__)
类 Mailer “myuser@mydomain.it”,
:from => "redmine@mydomain.it",
:subject => "测试邮件") 做 |format|
格式.文本
格式.html
结尾
结尾
结尾
电子邮件 = Mailer.daily_email
发送电子邮件
email.deliver
这是一封短信 这是一个变量
这是脚本的输出
rmadmin@redmineserver:~/scripts$ ruby test_mail.rb
D, [2020-06-26T08:59:34.798706 #1340] DEBUG -- : Mailer#daily_email: processed outbound mail in 1396.4ms
Date: Fri, 26 Jun 2020 08:59:34 +0000
From: redmine@mydomain.it
To: myuser@mydomain.it
Message-ID: <5ef5b8f6c48f6_53c208-492@redmineserver.mail>
Subject: testing mail
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
This is a text email
and this is a variable var
I, [2020-06-26T08:59:39.961850 #1340] INFO -- : Delivered mail 5ef5b8f6c48f6_53c208-492@uburedmine.mail (5152.0ms)
D, [2020-06-26T08:59:39.962362 #1340] DEBUG -- : Date: Fri, 26 Jun 2020 08:59:34 +0000
From: redmine@mydomain.it
To: myuser@mydomain.it
Message-ID: <5ef5b8f6c48f6_53c208-492@uburedmine.mail>
Subject: testing mail
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
This is a text email
and this is a variable var
Traceback (most recent call last):
16: from test_mail.rb:36:in `<main>'
15: from /usr/lib/ruby/2.7.0/delegate.rb:83:in `method_missing'
14: from /var/lib/gems/2.7.0/gems/mail-2.7.1/lib/mail/message.rb:260:in `deliver'
13: from /var/lib/gems/2.7.0/gems/actionmailer-6.0.3.2/lib/action_mailer/base.rb:587:in `deliver_mail'
12: from /var/lib/gems/2.7.0/gems/activesupport-6.0.3.2/lib/active_support/notifications.rb:180:in `instrument'
11: from /var/lib/gems/2.7.0/gems/activesupport-6.0.3.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
10: from /var/lib/gems/2.7.0/gems/activesupport-6.0.3.2/lib/active_support/notifications.rb:180:in `block in instrument'
9: from /var/lib/gems/2.7.0/gems/actionmailer-6.0.3.2/lib/action_mailer/base.rb:589:in `block in deliver_mail'
8: from /var/lib/gems/2.7.0/gems/mail-2.7.1/lib/mail/message.rb:260:in `block in deliver'
7: from /var/lib/gems/2.7.0/gems/mail-2.7.1/lib/mail/message.rb:2159:in `do_delivery'
6: from /var/lib/gems/2.7.0/gems/mail-2.7.1/lib/mail/network/delivery_methods/smtp.rb:100:in `deliver!'
5: from /var/lib/gems/2.7.0/gems/mail-2.7.1/lib/mail/network/delivery_methods/smtp.rb:109:in `start_smtp_session'
4: from /usr/lib/ruby/2.7.0/net/smtp.rb:518:in `start'
3: from /usr/lib/ruby/2.7.0/net/smtp.rb:552:in `do_start'
2: from /usr/lib/ruby/2.7.0/net/smtp.rb:584:in `tlsconnect'
1: from /usr/lib/ruby/2.7.0/net/protocol.rb:44:in `ssl_socket_connect'
/usr/lib/ruby/2.7.0/net/protocol.rb:44:in `connect_nonblock': SSL_connect returned=1 errno=0 state=error: unsupported protocol (OpenSSL::SSL::SSLError)
我已经在电子邮件客户端中尝试了 smtp 参数并且它们有效。
我正在从旧的 Ubuntu 16.04 服务器上的 redmine 安装迁移,在该服务器上可以发送邮件。
我尝试了许多配置变体,但均未成功。我开始认为 Ubuntu 20.04 和 Ubuntu 16.04 使用的 openssl 版本有所不同,但我无法检查这些信息的位置以及是否可以告诉 ActionMailer 使用不同版本的 ssl。
有些答案,例如this one 不适用,因为太旧了。
这是openssl version -a的输出
OpenSSL 1.1.1f 31 Mar 2020
built on: Mon Apr 20 11:53:50 2020 UTC
platform: debian-amd64
options: bn(64,64) rc4(16x,int) des(int) blowfish(ptr)
compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -Wa,--noexecstack -g -O2 -fdebug-prefix-map=/build/openssl-P_ODHM/openssl-1.1.1f=. -fstack-protector-strong -Wformat -Werror=format-security -DOPENSSL_TLS_SECURITY_LEVEL=2 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAESNI_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DNDEBUG -Wdate-time -D_FORTIFY_SOURCE=2
OPENSSLDIR: "/usr/lib/ssl"
ENGINESDIR: "/usr/lib/x86_64-linux-gnu/engines-1.1"
Seeding source: os-specific
我也试过modify the openssl configuration,没有结果。
我应该怎么做才能在 Ubuntu 20.04 上解决 ruby 上的这个 ssl 问题?
【问题讨论】:
标签: ruby email openssl actionmailer ubuntu-20.04