From d28f572ce5ef57b75085729c5b7baf5c17ab03f1 Mon Sep 17 00:00:00 2001 From: Guillaume Rousse <guillaume.rousse@renater.fr> Date: Thu, 26 Jul 2018 13:35:07 +0200 Subject: [PATCH] MIME-encode emails headers if needed --- lib/AccountManager/App.pm | 4 +++- templates/mail/send_authentication_token.tt2.eml | 2 +- templates/renater/mail/send_authentication_token.tt2.eml | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/AccountManager/App.pm b/lib/AccountManager/App.pm index 2838334..40c3b15 100644 --- a/lib/AccountManager/App.pm +++ b/lib/AccountManager/App.pm @@ -5,6 +5,7 @@ use warnings; use CGI; use DateTime; +use Encode; use English qw(-no_match_vars); use Log::Any::Adapter; use List::MoreUtils qw(uniq); @@ -590,7 +591,8 @@ sub req_complete_challenge { my $tt2 = Template->new({ ENCODING => 'utf8', PRE_CHOMP => CHOMP_ONE, - INCLUDE_PATH => $self->{configuration}->{setup}->{templates_dir} . "/mail" + INCLUDE_PATH => $self->{configuration}->{setup}->{templates_dir} . "/mail", + FILTERS => { mime => [ sub { return encode("MIME-Header", $_[0]); }, 0 ] }, }); my $template = 'send_authentication_token.tt2.eml'; my $data = { diff --git a/templates/mail/send_authentication_token.tt2.eml b/templates/mail/send_authentication_token.tt2.eml index 8960968..ca2a373 100644 --- a/templates/mail/send_authentication_token.tt2.eml +++ b/templates/mail/send_authentication_token.tt2.eml @@ -1,6 +1,6 @@ From: eduGAIN Access Check <[% from %]> To: [% to %] -Subject: eduGAIN Access Check - [% lh.maketext("Test accounts request") %] +Subject: eduGAIN Access Check - [% lh.maketext("Test accounts request") | mime %] Content-type: text/plain; charset=UTF-8; format=flowed [% lh.maketext("This is an email challenge automatically sent to you by eduGAIN Access Check.") %] diff --git a/templates/renater/mail/send_authentication_token.tt2.eml b/templates/renater/mail/send_authentication_token.tt2.eml index 8960968..ca2a373 100644 --- a/templates/renater/mail/send_authentication_token.tt2.eml +++ b/templates/renater/mail/send_authentication_token.tt2.eml @@ -1,6 +1,6 @@ From: eduGAIN Access Check <[% from %]> To: [% to %] -Subject: eduGAIN Access Check - [% lh.maketext("Test accounts request") %] +Subject: eduGAIN Access Check - [% lh.maketext("Test accounts request") | mime %] Content-type: text/plain; charset=UTF-8; format=flowed [% lh.maketext("This is an email challenge automatically sent to you by eduGAIN Access Check.") %] -- GitLab