FIX: Prioritize VERP key over final_recipient header in bounced email

Per RFC3464 2.3.2, the final_recipient header may not match the address we originally sent the email to.
This commit is contained in:
David Taylor
2019-05-03 12:12:44 +01:00
parent 0d41d58d27
commit 0644c10bfe
3 changed files with 51 additions and 4 deletions

View File

@ -513,13 +513,13 @@ module Email
def parse_from_field(mail = nil)
mail ||= @mail
if mail.bounced?
if email_log.present?
email = email_log.to_address || email_log.user&.email
return [email, email_log.user&.username]
elsif mail.bounced?
Array.wrap(mail.final_recipient).each do |from|
return extract_from_address_and_name(from)
end
elsif email_log.present?
email = email_log.user&.email || email_log.to_address
return [email, email_log.user&.username]
end
return unless mail[:from]