From e9bae618ed68f9b7a9a6dafff4a87beb2f6232e3 Mon Sep 17 00:00:00 2001 From: Patrick Gansterer Date: Tue, 3 Oct 2017 09:46:09 +0200 Subject: [PATCH] Add workaround for mails with UTF-8 characters in To header --- app/mailers/mailer.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/mailers/mailer.rb b/app/mailers/mailer.rb index 8182d0e2..21b8f9bb 100644 --- a/app/mailers/mailer.rb +++ b/app/mailers/mailer.rb @@ -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