mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 19:53:53 -06:00
FIX: bounced email can contain multiple status codes
This commit is contained in:
parent
7ca2e6a80c
commit
ceb7590bcb
@ -169,7 +169,7 @@ module Email
|
||||
|
||||
email ||= @from_email
|
||||
|
||||
if @mail.error_status.present? && @mail.error_status.start_with?("4.")
|
||||
if @mail.error_status.present? && Array.wrap(@mail.error_status).any? { |s| s.start_with?("4.") }
|
||||
Email::Receiver.update_bounce_score(email, SiteSetting.soft_bounce_score)
|
||||
else
|
||||
Email::Receiver.update_bounce_score(email, SiteSetting.hard_bounce_score)
|
||||
|
@ -81,6 +81,9 @@ describe Email::Receiver do
|
||||
it "raises a BouncerEmailError when email is a bounced email" do
|
||||
expect { process(:bounced_email) }.to raise_error(Email::Receiver::BouncedEmailError)
|
||||
expect(IncomingEmail.last.is_bounce).to eq(true)
|
||||
|
||||
expect { process(:bounced_email_multiple_status_codes) }.to raise_error(Email::Receiver::BouncedEmailError)
|
||||
expect(IncomingEmail.last.is_bounce).to eq(true)
|
||||
end
|
||||
|
||||
it "logs a blank error" do
|
||||
|
45
spec/fixtures/emails/bounced_email_multiple_status_codes.eml
vendored
Normal file
45
spec/fixtures/emails/bounced_email_multiple_status_codes.eml
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
Delivered-To: someguy@discourse.org
|
||||
Date: Thu, 7 Apr 2016 19:04:30 +0900 (JST)
|
||||
From: MAILER-DAEMON@b-s-c.co.jp (Mail Delivery System)
|
||||
Subject: Undelivered Mail Returned to Sender
|
||||
To: someguy@discourse.org
|
||||
MIME-Version: 1.0
|
||||
Content-Type: multipart/report; report-type=delivery-status;
|
||||
boundary="18F5D18A0075.1460023470/some@daemon.com"
|
||||
|
||||
This is a MIME-encapsulated message.
|
||||
|
||||
--18F5D18A0075.1460023470/some@daemon.com
|
||||
Content-Description: Notification
|
||||
Content-Type: text/plain; charset=us-ascii
|
||||
|
||||
Your email bounced
|
||||
|
||||
--18F5D18A0075.1460023470/some@daemon.com
|
||||
Content-Description: Delivery report
|
||||
Content-Type: message/delivery-status
|
||||
|
||||
Final-Recipient: rfc822; linux-admin@b-s-c.co.jp
|
||||
Original-Recipient: rfc822;linux-admin@b-s-c.co.jp
|
||||
Action: failed
|
||||
Status: 5.1.1
|
||||
Diagnostic-Code: X-Postfix; unknown user: "linux-admin"
|
||||
|
||||
Final-Recipient: rfc822; foo@b-s-c.co.jp
|
||||
Original-Recipient: rfc822;linux-admin@b-s-c.co.jp
|
||||
Action: failed
|
||||
Status: 5.1.1
|
||||
Diagnostic-Code: X-Postfix; unknown user: "foo"
|
||||
|
||||
--18F5D18A0075.1460023470/some@daemon.com
|
||||
Content-Description: Undelivered Message
|
||||
Content-Type: message/rfc822
|
||||
|
||||
Return-Path: <someguy@discourse.org>
|
||||
Date: Thu, 07 Apr 2016 03:04:28 -0700 (PDT)
|
||||
From: someguy@discourse.org
|
||||
X-Discourse-Auto-Generated: marked
|
||||
|
||||
This is the body
|
||||
|
||||
--18F5D18A0075.1460023470/some@daemon.com--
|
Loading…
Reference in New Issue
Block a user