mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
FIX: Add higher read & open timeouts for group SMTP emails (#24593)
When sending SMTP for group SMTP functionality, we are running into timeouts for both read and open when sending mail occassionally, which can cause issues like the email only being sent to _some_ of the recipients or to fail altogether. The defaults of 5s are too low, so bumping them up to the defaults of the `net-smtp` gem.
This commit is contained in:
parent
1fc0ce1ac2
commit
3e639e4aa7
|
@ -18,6 +18,8 @@ class GroupSmtpMailer < ActionMailer::Base
|
|||
authentication: 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_preferred
|
||||
|
|
|
@ -98,6 +98,14 @@ smtp_open_timeout = 5
|
|||
# Number of seconds to wait until timing-out a SMTP read(2) call
|
||||
smtp_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 developers
|
||||
load_mini_profiler = true
|
||||
|
||||
|
|
|
@ -117,6 +117,24 @@ RSpec.describe GroupSmtpMailer do
|
|||
expect(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: "bugs@gmail.com",
|
||||
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" do
|
||||
before do
|
||||
SiteSetting.manual_polling_enabled = true
|
||||
|
|
Loading…
Reference in New Issue
Block a user