A platform for community discussion. Free, open, simple.
FIX: Ignore DMARC for emails sent to mailing list mirror
Gerhard Schlagerc88797bf0eb6
diff --git a/lib/email/receiver.rb b/lib/email/receiver.rbindex 836405aae50..06b2700cdfb 100644--- a/lib/email/receiver.rb+++ b/lib/email/receiver.rb@@ -199,7 +199,7 @@ module Email@hidden_reason_id ||=if is_spam?Post.hidden_reasons[:email_spam_header_found]- elsif auth_res_action == :hide+ elsif !sent_to_mailinglist_mirror? && auth_res_action == :hidePost.hidden_reasons[:email_authentication_result_header]elsenildiff --git a/spec/components/email/receiver_spec.rb b/spec/components/email/receiver_spec.rbindex 400f72385c7..b4b95ae52ca 100644--- a/spec/components/email/receiver_spec.rb+++ b/spec/components/email/receiver_spec.rb@@ -1422,6 +1422,14 @@ describe Email::Receiver doexpect { process("mailinglist_unsubscribe") }.to_not change { ActionMailer::Base.deliveries.count }end++ it "ignores dmarc fails" do+ expect { process("mailinglist_dmarc_fail") }.to change { Topic.count }++ post = Topic.last.first_post+ expect(post.hidden).to eq(false)+ expect(post.hidden_reason_id).to be_nil+ endendit "tries to fix unparsable email addresses in To and CC headers" dodiff --git a/spec/fixtures/emails/mailinglist_dmarc_fail.eml b/spec/fixtures/emails/mailinglist_dmarc_fail.emlnew file mode 100644index 00000000000..d64617e4e55--- /dev/null+++ b/spec/fixtures/emails/mailinglist_dmarc_fail.eml@@ -0,0 +1,13 @@+Authentication-Results: example.com; dmarc=fail+From: [email protected]+To: [email protected]+Subject: mailinglist mirror+Date: Mon, 16 Oct 2017 09:18:32 +0100+Message-ID: <[email protected]>+Precedence: list+List-Id: Example List <[email protected]>+Content-Transfer-Encoding: 7bit+Content-Type: text/plain; charset="us-ascii"+Sender: [email protected]++I love Discourse's mailinglist mirror feature.