Add workaround for mails with UTF-8 characters in To header

This commit is contained in:
Patrick Gansterer 2017-10-03 09:46:09 +02:00
parent 463e448351
commit e9bae618ed
1 changed files with 3 additions and 1 deletions

View File

@ -95,7 +95,9 @@ class Mailer < ActionMailer::Base
reply_email_domain = FoodsoftConfig[:reply_email_domain]
if reply_email_domain && !args[:return_path]
address = Mail::Parsers::AddressListsParser.new.parse(args[:to]).addresses.first
#TODO: Remove workaround for https://github.com/mikel/mail/issues/39 after next mail release
ascii_to = args[:to].encode('ASCII', invalid: :replace, undef: :replace, replace: '_')
address = Mail::Parsers::AddressListsParser.new.parse(ascii_to).addresses.first
args[:return_path] = "<#{FoodsoftConfig.scope}.bounce+#{address.local}=#{address.domain}@#{reply_email_domain}>"
end