Merge pull request #5372 from betagouv/ignore-invalid-emails
Mailers : d'autres d'erreurs SMTP sont maintenant ignorées
This commit is contained in:
commit
45d6ba6b69
3 changed files with 22 additions and 2 deletions
|
@ -8,6 +8,12 @@ class ApplicationMailer < ActionMailer::Base
|
||||||
message.perform_deliveries = false
|
message.perform_deliveries = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
rescue_from Net::SMTPServerBusy do |error|
|
||||||
|
if error.message =~ /unexpected recipients/
|
||||||
|
message.perform_deliveries = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Attach the procedure logo to the email (if any).
|
# Attach the procedure logo to the email (if any).
|
||||||
# Returns the attachment url.
|
# Returns the attachment url.
|
||||||
def attach_logo(procedure)
|
def attach_logo(procedure)
|
||||||
|
|
|
@ -9,6 +9,12 @@ class DeviseUserMailer < Devise::Mailer
|
||||||
message.perform_deliveries = false
|
message.perform_deliveries = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
rescue_from Net::SMTPServerBusy do |error|
|
||||||
|
if error.message =~ /unexpected recipients/
|
||||||
|
message.perform_deliveries = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def template_paths
|
def template_paths
|
||||||
['devise_mailer']
|
['devise_mailer']
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,10 +7,18 @@ RSpec.describe ApplicationMailer, type: :mailer do
|
||||||
before do
|
before do
|
||||||
allow_any_instance_of(DossierMailer)
|
allow_any_instance_of(DossierMailer)
|
||||||
.to receive(:notify_new_draft)
|
.to receive(:notify_new_draft)
|
||||||
.and_raise(Net::SMTPSyntaxError)
|
.and_raise(smtp_error)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(subject.message).to be_an_instance_of(ActionMailer::Base::NullMail) }
|
context 'when the server handles invalid emails with Net::SMTPSyntaxError' do
|
||||||
|
let(:smtp_error) { Net::SMTPSyntaxError.new }
|
||||||
|
it { expect(subject.message).to be_an_instance_of(ActionMailer::Base::NullMail) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when the server handles invalid emails with Net::SMTPServerBusy' do
|
||||||
|
let(:smtp_error) { Net::SMTPServerBusy.new('400 unexpected recipients: want atleast 1, got 0') }
|
||||||
|
it { expect(subject.message).to be_an_instance_of(ActionMailer::Base::NullMail) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'valid emails are sent' do
|
describe 'valid emails are sent' do
|
||||||
|
|
Loading…
Reference in a new issue