Skip to content

A platform for community discussion. Free, open, simple.

FIX: Don't reply to Unsubscribe email sent to mailing list mirror

Gerhard Schlager7a41a783a4e9
diff --git a/lib/email/receiver.rb b/lib/email/receiver.rb
index 618556691c8..d0d6379880b 100644
--- a/lib/email/receiver.rb
+++ b/lib/email/receiver.rb
@@ -838,6 +838,8 @@ module Email
def subscription_action_for(body, subject)
return unless SiteSetting.unsubscribe_via_email
+ return if sent_to_mailinglist_mirror?
+
if ([subject, body].compact.map(&:to_s).map(&:downcase) & ['unsubscribe']).any?
:confirm_unsubscribe
end
diff --git a/spec/components/email/receiver_spec.rb b/spec/components/email/receiver_spec.rb
index 8248e6024bc..3eface946d8 100644
--- a/spec/components/email/receiver_spec.rb
+++ b/spec/components/email/receiver_spec.rb
@@ -1103,6 +1103,13 @@ describe Email::Receiver do
expect { process(:mailinglist_reply) }.to change { topic.posts.count }
end
end
+
+ it "ignores unsubscribe email" do
+ SiteSetting.unsubscribe_via_email = true
+ Fabricate(:user, email: "[email protected]")
+
+ expect { process("mailinglist_unsubscribe") }.to_not change { ActionMailer::Base.deliveries.count }
+ end
end
it "tries to fix unparsable email addresses in To and CC headers" do
diff --git a/spec/fixtures/emails/mailinglist_unsubscribe.eml b/spec/fixtures/emails/mailinglist_unsubscribe.eml
new file mode 100644
index 00000000000..47dcaeafaf6
--- /dev/null
+++ b/spec/fixtures/emails/mailinglist_unsubscribe.eml
@@ -0,0 +1,11 @@
+Return-Path: <[email protected]>
+Date: Thu, 13 Jun 2013 17:03:48 -0400
+Message-ID: <[email protected]>
+Subject: UnSuBScRiBe
+Mime-Version: 1.0
+Content-Type: text/plain;
+Content-Transfer-Encoding: 7bit
+
+I've basically had enough of your mailing list and would very much like it if you went away.