mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
use 'reply_by_email_address' setting for handling bounce emails using VERP
This commit is contained in:
parent
e3f42d7038
commit
84d4ebd910
@ -819,7 +819,6 @@ en:
|
|||||||
title: "The name of this site, as used in the title tag."
|
title: "The name of this site, as used in the title tag."
|
||||||
site_description: "Describe this site in one sentence, as used in the meta description tag."
|
site_description: "Describe this site in one sentence, as used in the meta description tag."
|
||||||
contact_email: "Email address of key contact responsible for this site. Used for critical notifications such as unhandled flags, as well as on the /about contact form for urgent matters."
|
contact_email: "Email address of key contact responsible for this site. Used for critical notifications such as unhandled flags, as well as on the /about contact form for urgent matters."
|
||||||
bounce_email: "Variable Email Return Path used for emails, example: bounce@example.com will cause us to generate bounce+GUID@example.com as the Return Path for emails we send. This feature allows us to automatically disable bouncing emails. Requires additional configurations, leave blank if unsure."
|
|
||||||
contact_url: "Contact URL for this site. Used on the /about contact form for urgent matters."
|
contact_url: "Contact URL for this site. Used on the /about contact form for urgent matters."
|
||||||
queue_jobs: "DEVELOPER ONLY! WARNING! By default, queue jobs in sidekiq. If disabled, your site will be broken."
|
queue_jobs: "DEVELOPER ONLY! WARNING! By default, queue jobs in sidekiq. If disabled, your site will be broken."
|
||||||
crawl_images: "Retrieve images from remote URLs to insert the correct width and height dimensions."
|
crawl_images: "Retrieve images from remote URLs to insert the correct width and height dimensions."
|
||||||
|
@ -26,10 +26,6 @@ required:
|
|||||||
client: true
|
client: true
|
||||||
default: ''
|
default: ''
|
||||||
type: email
|
type: email
|
||||||
bounce_email:
|
|
||||||
default: ''
|
|
||||||
type: email
|
|
||||||
shadowed_by_global: true
|
|
||||||
contact_url:
|
contact_url:
|
||||||
client: true
|
client: true
|
||||||
default: ''
|
default: ''
|
||||||
|
@ -116,16 +116,13 @@ module Email
|
|||||||
@message.header['List-Post'] = "<mailto:#{email}>"
|
@message.header['List-Post'] = "<mailto:#{email}>"
|
||||||
end
|
end
|
||||||
|
|
||||||
unless SiteSetting.bounce_email.blank?
|
if SiteSetting.reply_by_email_address.present? && SiteSetting.reply_by_email_address["+"]
|
||||||
email_log.bounce_key = SecureRandom.hex
|
email_log.bounce_key = SecureRandom.hex
|
||||||
address,domain = SiteSetting.bounce_email.split('@')
|
|
||||||
address << (address =~ /[+]/ ? "-" : '+')
|
|
||||||
address << email_log.bounce_key
|
|
||||||
|
|
||||||
# WARNING: RFC claims you can not set the Return Path header, this is 100% correct
|
# WARNING: RFC claims you can not set the Return Path header, this is 100% correct
|
||||||
# however Rails has special handling for this header and ends up using this value
|
# however Rails has special handling for this header and ends up using this value
|
||||||
# as the Envelope From address so stuff works as expected
|
# as the Envelope From address so stuff works as expected
|
||||||
@message.header[:return_path] = "#{address}@#{domain}"
|
@message.header[:return_path] = SiteSetting.reply_by_email_address.sub("%{reply_key}", "verp-#{email_log.bounce_key}")
|
||||||
end
|
end
|
||||||
|
|
||||||
email_log.post_id = post_id if post_id.present?
|
email_log.post_id = post_id if post_id.present?
|
||||||
|
@ -77,25 +77,21 @@ describe Email::Sender do
|
|||||||
email_sender.send
|
email_sender.send
|
||||||
end
|
end
|
||||||
|
|
||||||
context "adds return_path correctly when no plus addressing" do
|
context "doesn't add return_path when no plus addressing" do
|
||||||
before do
|
before { SiteSetting.reply_by_email_address = '%{reply_key}@test.com' }
|
||||||
SiteSetting.bounce_email = 'bounce@test.com'
|
|
||||||
end
|
|
||||||
|
|
||||||
When { email_sender.send }
|
When { email_sender.send }
|
||||||
Then {
|
Then {
|
||||||
expect(message.header[:return_path].to_s).to eq("bounce+#{EmailLog.last.bounce_key}@test.com")
|
expect(message.header[:return_path].to_s).to eq("")
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
context "adds return_path correctly with plus addressing" do
|
context "adds return_path with plus addressing" do
|
||||||
before do
|
before { SiteSetting.reply_by_email_address = 'replies+%{reply_key}@test.com' }
|
||||||
SiteSetting.bounce_email = 'bounce+meta@test.com'
|
|
||||||
end
|
|
||||||
|
|
||||||
When { email_sender.send }
|
When { email_sender.send }
|
||||||
Then {
|
Then {
|
||||||
expect(message.header[:return_path].to_s).to eq("bounce+meta-#{EmailLog.last.bounce_key}@test.com")
|
expect(message.header[:return_path].to_s).to eq("replies+verp-#{EmailLog.last.bounce_key}@test.com")
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user