Skip to content

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

FIX: Remove List-Unsubscribe header if using group SMTP (#13448)

Martin Brennanf0c10edd2813
diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rb
index a63c7b14477..7f8ce6f5f62 100644
--- a/app/mailers/user_notifications.rb
+++ b/app/mailers/user_notifications.rb
@@ -492,6 +492,7 @@ class UserNotifications < ActionMailer::Base
from_address = nil
delivery_method_options = nil
use_from_address_for_reply_to = false
+ using_group_smtp = false
template = +"user_notifications.user_#{notification_type}"
if post.topic.private_message?
@@ -562,6 +563,7 @@ class UserNotifications < ActionMailer::Base
# will forward the email back into Discourse and process/link it correctly.
use_from_address_for_reply_to = true
from_address = group.email_username
+ using_group_smtp = true
end
if post.topic.private_message?
@@ -711,7 +713,8 @@ class UserNotifications < ActionMailer::Base
locale: locale,
delivery_method_options: delivery_method_options,
use_from_address_for_reply_to: use_from_address_for_reply_to,
- from: from_address
+ from: from_address,
+ add_unsubscribe_link: !using_group_smtp
}
unless translation_override_exists
diff --git a/spec/components/email/sender_spec.rb b/spec/components/email/sender_spec.rb
index 27e93515afa..3c56e932443 100644
--- a/spec/components/email/sender_spec.rb
+++ b/spec/components/email/sender_spec.rb
@@ -375,6 +375,7 @@ describe Email::Sender do
expect(message.header['List-Post']).to eq(nil)
expect(message.header['List-Archive']).to eq(nil)
expect(message.header['Precedence']).to eq(nil)
+ expect(message.header['List-Unsubscribe']).to eq(nil)
end
end
end