Defect #37753

Cannot send mail through smtp due to TLS errors

Added by Gasper C about 1 month ago. Updated about 1 month ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Email notifications
Target version:-
Resolution: Affected version:5.0.2

Description

Hello,

I've updated redmine to 5.0.2 from v3.2.0.

I've kept SMTP settings the same and noticed that I cannot send mails anymore.

The error that keeps appearing is:
Oct 05 13:23:36 acred2p redmine214934: E, [2022-10-05T13:23:36.935478 #215008] ERROR -- : [ActiveJob] [ActionMailer::MailDeliveryJob] [4f9f26ee-e713-460d-97d9-49f5f69d3cba] Email delivery error: SSL_connect returned=1 errno=0 peeraddr=10.x.y.z:25 state=error: unexpected eof while reading

From the logs on the SMTP server it seems that the problem is TLS - mail server admin advised to turn it off.

I've tried the following settings in various configurations and nothing seemed to work:

production:
email_delivery:
delivery_method: :smtp
smtp_settings:
address: 10.x.y.z
port: 25
domain: xxxxxxx
enable_starttls_auto: false
openssl_verify_mode: 'none'
tls: false
ssl: false

The bottom 3 lines were added - otherwise the config worked in redmine v3.

SMTP server is working as expected - I can send a mail manually from the redmine server through the terminal.

Any help is appreciated, thanks.

History

#1 Updated by Pavel Rosický about 1 month ago

it's a bug, but since the mail gem maintainer is inactive for a long time, I don't expect any fixes soon.

you have 2 options:
1/ use SSL
2/ apply an unofficial patch, see https://github.com/mikel/mail/pull/1435

#2 Updated by Dmitry Makurin about 1 month ago

Try this:

production:
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      address: xxxxxxx
      port: 25
      disable_start_tls: true
      openssl_verify_mode: "none" 

After upgrade to redmine 5.0 i have encountered the same issue. Config above managed to fix it without modifying mail gem.

#3 Updated by Gasper C about 1 month ago

Thanks @Pavel & @Dmitry - I think I'll have to try to modify the gem. I tried pasting Dmitry's config but the result is the same - there must be a difference in our SMTP servers.

#4 Updated by Gasper C about 1 month ago

I've forked a branch from mail 2.8.0-stable and added jeremy's patch in there, with one fix.

In case it ever helps anyone, just clone this and build the gem.
https://github.com/GChuf/mail/tree/2-8-stable

git clone https://github.com/GChuf/mail/
git checkout 2-8-stable
cd mail
gem build mail.gemspec
gem install mail -v2.8.0.patch

After that, change the mail version in redmine's Gemfile.

#5 Updated by Pavel Rosický about 1 month ago

FYI there's a breaking change in 2.8 https://github.com/redmine/redmine/blob/master/app/models/mail_handler.rb#L528

Mail::RubyVer.pick_encoding(p.charset).to_s

has to be changed to
Mail::Utilities.pick_encoding(p.charset).to_s

but it may not affect you unless you're a helpdesk user

#6 Updated by Gasper C about 1 month ago

Thanks Pavel,

helpdesk as in redmine helpdesk plugin?

In any case - it makes sense to patch the 2.7. branch and use that, then.

#8 Updated by Gasper C about 1 month ago

Thanks for all the help.
I created a patched branch of 2-7-stable as well (2.7.2).

https://github.com/GChuf/mail/tree/2-7-stable

Also available in: Atom PDF