use 'reply_by_email_address' setting for handling bounce emails using VERP

This commit is contained in:
Régis Hanol
2016-04-25 20:06:45 +02:00
parent e3f42d7038
commit 84d4ebd910
4 changed files with 8 additions and 20 deletions

View File

@@ -116,16 +116,13 @@ module Email
@message.header['List-Post'] = "<mailto:#{email}>"
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?