mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 17:06:31 -06:00
FIX: Strip Auto-Submitted email header from group SMTP emails (#15057)
Remove Auto-Submitted header for group private message emails, it does not make sense there and may hurt deliverability. From https://www.iana.org/assignments/auto-submitted-keywords/auto-submitted-keywords.xhtml: > Indicates that a message was generated by an automatic process, and is not a direct response to another message.
This commit is contained in:
parent
d40e56272f
commit
44be79f095
@ -213,9 +213,20 @@ module Email
|
||||
@message.header[Email::MessageBuilder::ALLOW_REPLY_BY_EMAIL_HEADER] = nil
|
||||
end
|
||||
|
||||
# Replace reply_key in custom headers or remove
|
||||
MessageBuilder.custom_headers(SiteSetting.email_custom_headers).each do |key, _|
|
||||
value = header_value(key)
|
||||
|
||||
# Remove Auto-Submitted header for group private message emails, it does
|
||||
# not make sense there and may hurt deliverability.
|
||||
#
|
||||
# From https://www.iana.org/assignments/auto-submitted-keywords/auto-submitted-keywords.xhtml:
|
||||
#
|
||||
# > Indicates that a message was generated by an automatic process, and is not a direct response to another message.
|
||||
if key.downcase == "auto-submitted" && smtp_group_id
|
||||
@message.header[key] = nil
|
||||
end
|
||||
|
||||
# Replace reply_key in custom headers or remove
|
||||
if value&.include?('%{reply_key}')
|
||||
# Delete old header first or else the same header will be added twice
|
||||
@message.header[key] = nil
|
||||
|
@ -414,6 +414,13 @@ describe Email::Sender do
|
||||
expect(message.header['Precedence']).to eq(nil)
|
||||
expect(message.header['List-Unsubscribe']).to eq(nil)
|
||||
end
|
||||
|
||||
it "removes the Auto-Submitted header" do
|
||||
TopicAllowedGroup.create!(topic: post.topic, group: group)
|
||||
email_sender.send
|
||||
|
||||
expect(message.header['Auto-Submitted']).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user