diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index ffb0b9020f2..78c60a071fa 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -819,7 +819,6 @@ en: 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." 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." 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." diff --git a/config/site_settings.yml b/config/site_settings.yml index 183ff1a5550..bc2bb0708b6 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -26,10 +26,6 @@ required: client: true default: '' type: email - bounce_email: - default: '' - type: email - shadowed_by_global: true contact_url: client: true default: '' diff --git a/lib/email/sender.rb b/lib/email/sender.rb index 4a682b20ccb..e1d0b320b00 100644 --- a/lib/email/sender.rb +++ b/lib/email/sender.rb @@ -116,16 +116,13 @@ module Email @message.header['List-Post'] = "" end - unless SiteSetting.bounce_email.blank? + if SiteSetting.reply_by_email_address.present? && SiteSetting.reply_by_email_address["+"] 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 # however Rails has special handling for this header and ends up using this value # 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 email_log.post_id = post_id if post_id.present? diff --git a/spec/components/email/sender_spec.rb b/spec/components/email/sender_spec.rb index 073890b2fb8..89d299dda4e 100644 --- a/spec/components/email/sender_spec.rb +++ b/spec/components/email/sender_spec.rb @@ -77,25 +77,21 @@ describe Email::Sender do email_sender.send end - context "adds return_path correctly when no plus addressing" do - before do - SiteSetting.bounce_email = 'bounce@test.com' - end + context "doesn't add return_path when no plus addressing" do + before { SiteSetting.reply_by_email_address = '%{reply_key}@test.com' } When { email_sender.send } 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 - context "adds return_path correctly with plus addressing" do - before do - SiteSetting.bounce_email = 'bounce+meta@test.com' - end + context "adds return_path with plus addressing" do + before { SiteSetting.reply_by_email_address = 'replies+%{reply_key}@test.com' } When { email_sender.send } 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