mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Following the Rails 7 upgrade, the `DISCOURSE_SMTP_ENABLE_START_TLS` setting doesn’t work anymore. This is because Rails upgraded the `net-smtp` gem to the 0.3.1 version which enables `starttls` by default. The `mail` gem doesn’t support this new behavior yet and doesn’t know how to disable TLS. This should be fixed in an upcoming release. Meanwhile applying this patch allows us to get back the previous behavior which is expected by many.
22 lines
609 B
Ruby
22 lines
609 B
Ruby
# frozen_string_literal: true
|
|
|
|
# Patch from
|
|
# https://github.com/rails/rails/issues/44698#issuecomment-1069675285 to enable
|
|
# previous behavior with Net::SMTP regarding TLS.
|
|
#
|
|
# This should be fixed in an upcoming release of the Mail gem (probably 2.8),
|
|
# when this patch is merged: https://github.com/mikel/mail/pull/1435
|
|
module FreedomPatches::MailDisableStarttls
|
|
def build_smtp_session
|
|
super.tap do |smtp|
|
|
unless settings[:enable_starttls_auto]
|
|
if smtp.respond_to?(:disable_starttls)
|
|
smtp.disable_starttls
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
::Mail::SMTP.prepend(self)
|
|
end
|