I've just installed a Ubuntu 20.04 server and I've installed redmine, but mail sending with ssl enabled does not work.
So I've started some tests for sending an email with ruby.
I've seen a way to send a mail in this post, so I've tried to do the same thing with a script and related mailer/daily_email.text.erb
:
ActionMailer::Base.raise_delivery_errors = true ActionMailer::Base.logger = Logger.new (STDOUT) ActionMailer::Base.logger.level = Logger::DEBUG ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.smtp_settings = { :address => "smtps.aruba.it", :port => 465, :domain => "mydomain.it", :authentication => :login, :user_name => "[email protected]", :password => "mypassword", :enable_starttls_auto => true, :ssl => true } ActionMailer::Base.view_paths= File.dirname(__FILE__) class Mailer < ActionMailer::Base def daily_email @var = "var" mail( :to => "[email protected]", :from => "[email protected]", :subject => "testing mail") do |format| format.text format.html end end end email = Mailer.daily_email puts email email.deliver
This is a text email and this is a variable <%= @var %>
This is the output of the script
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: [email protected]
To: [email protected]
Message-ID: <[email protected]>
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 [email protected] (5152.0ms)
D, [2020-06-26T08:59:39.962362 #1340] DEBUG -- : Date: Fri, 26 Jun 2020 08:59:34 +0000
From: [email protected]
To: [email protected]
Message-ID: <[email protected]>
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)
I've tried the smtp parameters in a email client and they works.
I'm migrating from a redmine installation from an old Ubuntu 16.04 server, where mail sending works.
I've tried many variations of the configuration without success. I'm starting to think that there's a difference in the openssl version used by Ubuntu 20.04 and Ubuntu 16.04, but I'm not able to check where this information is and if I can tell ActionMailer
to use a different version of ssl.
Some answers, like this one are not applicable because too old.
This is the output of 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
I've also tried to modify the openssl configuration, without results.
What should I do in order to fix this ssl problem on ruby on Ubuntu 20.04?