Skip to content

Patch mail gem to handle TLS settings properly

Stan Hu requested to merge sh-patch-mail-starttls into master

What does this MR do and why?

While https://github.com/mikel/mail/pull/1526 made it possible to disable STARTTLS with Ruby 3, there were a number of logic errors that were fixed in https://github.com/mikel/mail/pull/1536.

We pull in those changes so that existing users don't have to modify their configurations to omit tls and ssl settings to disable STARTTLS.

Relates to #399241 (closed)

How to set up and validate locally

First, on an Omnibus instance, copy config/initializers/mail_starttls_patch.rb to /opt/gitlab/embedded/service/gitlab-rails/config/initializers.

Verify with STARTTLS enabled

  1. Set up Gmail with GitLab: https://kifarunix.com/configure-gitlab-to-use-gmail-smtp-for-outbound-mails/
  2. Run gitlab-rails console: Notify.test_email('destination_email@address.com', 'Message Subject', 'Message Body').deliver_now

Verify with STARTTLS disabled

  1. Set up Postfix: https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-as-a-send-only-smtp-server-on-ubuntu-22-04
  2. Configure SMTP without SSL: https://docs.gitlab.com/omnibus/settings/smtp.html#smtp-without-ssl
  3. Run gitlab-rails console: Notify.test_email('destination_email@address.com', 'Message Subject', 'Message Body').deliver_now

Messages should be sent successfully in both cases.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Stan Hu

Merge request reports