Fix SMTP when TLS is disabled
What does this MR do?
This commit fixes mail sending when TLS is disabled. In Ruby 3.0.5, net-smtp v0.2.1 enabled TLS by default if the server advertises STARTTLS support. However, mail v2.7.1 didn't explicitly disable TLS (https://github.com/mikel/mail/issues/1434), so TLS may be used with Ruby 3 even if it is disabled. mail v2.8.1 has since fixed this issue via https://github.com/mikel/mail/pull/1480.
However, mail v2.8.1 has a bug in the logic for retrieving the settings (https://github.com/mikel/mail/blob/2.8.1/lib/mail/network/delivery_methods/smtp.rb#L114):
tls = settings[:tls] || settings[:ssl]
If settings[:tls]
is false
and settings[:ssl]
is nil
, then
the result of false || nil
is nil
.
This means that TLS cannot be disabled if settings[:tls]
is set to
false
.
To fix this, just add a redundant ssl
config parameter.
Related issues
This came out of gitlab-org/gitlab#399241 (closed).
Checklist
See Definition of done.
For anything in this list which will not be completed, please provide a reason in the MR discussion.
Required
-
Merge Request Title and Description are up to date, accurate, and descriptive -
MR targeting the appropriate branch -
MR has a green pipeline on GitLab.com -
When ready for review, MR is labeled "~workflow::ready for review" per the Distribution MR workflow
Expected (please provide an explanation if not completing)
-
Test plan indicating conditions for success has been posted and passes -
Documentation created/updated -
Tests added -
Integration tests added to GitLab QA -
Equivalent MR/issue for omnibus-gitlab opened -
Validate potential values for new configuration settings. Formats such as integer 10
, duration10s
, URIscheme://user:passwd@host:port
may require quotation or other special handling when rendered in a template and written to a configuration file.