A platform for community discussion. Free, open, simple.
FIX: Add higher read & open timeouts for group SMTP emails (#24593)
Martin Brennan3e639e4aa7bf
diff --git a/app/mailers/group_smtp_mailer.rb b/app/mailers/group_smtp_mailer.rbindex 5cd5836752a..708e46043f5 100644--- a/app/mailers/group_smtp_mailer.rb+++ b/app/mailers/group_smtp_mailer.rb@@ -18,6 +18,8 @@ class GroupSmtpMailer < ActionMailer::Baseauthentication: GlobalSetting.smtp_authentication,enable_starttls_auto: from_group.smtp_ssl,return_response: true,+ open_timeout: GlobalSetting.group_smtp_open_timeout,+ read_timeout: GlobalSetting.group_smtp_read_timeout,}group_name = from_group.name_full_preferreddiff --git a/config/discourse_defaults.conf b/config/discourse_defaults.confindex b0f9a466f1c..9fd3f0208a4 100644--- a/config/discourse_defaults.conf+++ b/config/discourse_defaults.conf@@ -98,6 +98,14 @@ smtp_open_timeout = 5# Number of seconds to wait until timing-out a SMTP read(2) callsmtp_read_timeout = 5+# number of seconds to wait while attempting to open a SMTP connection only when+# sending emails via group SMTP+group_smtp_open_timeout = 30++# Number of seconds to wait until timing-out a SMTP read(2) call only when sending+# emails via group SMTP+group_smtp_read_timeout = 60+# load MiniProfiler in production, to be used by developersload_mini_profiler = truediff --git a/spec/mailers/group_smtp_mailer_spec.rb b/spec/mailers/group_smtp_mailer_spec.rbindex ecd6d945099..09bbf72489c 100644--- a/spec/mailers/group_smtp_mailer_spec.rb+++ b/spec/mailers/group_smtp_mailer_spec.rb@@ -117,6 +117,24 @@ RSpec.describe GroupSmtpMailer doexpect(sent_mail.subject).to eq("Re: Hello from John")end+ it "configures delivery options for SMTP correctly" do+ mail = GroupSmtpMailer.send_mail(group, user.email, Fabricate(:post))+ expect(mail.delivery_method.settings).to eq(+ {+ address: "smtp.gmail.com",+ port: 587,+ domain: "gmail.com",+ user_name: "[email protected]",+ password: "super$secret$password",+ authentication: GlobalSetting.smtp_authentication,+ enable_starttls_auto: true,+ return_response: true,+ open_timeout: GlobalSetting.group_smtp_open_timeout,+ read_timeout: GlobalSetting.group_smtp_read_timeout,+ },+ )+ end+context "when the site has a reply by email address configured" dobefore doSiteSetting.manual_polling_enabled = true