2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 09:10:25 +08:00

FEATURE: add support for bounce emails

We now optionally add a Variable Email Return Path to every email we send.
This allows us to cleanly handle email bounces, which in turn will improve
deliverability.
This commit is contained in:
Sam 2016-04-18 17:13:41 +10:00
parent 9e25e4baa8
commit fad017d842
5 changed files with 44 additions and 0 deletions

View file

@ -116,6 +116,18 @@ module Email
@message.header['List-Post'] = "<mailto:#{email}>"
end
unless SiteSetting.bounce_email.blank?
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}"
end
email_log.post_id = post_id if post_id.present?
email_log.reply_key = reply_key if reply_key.present?