diff --git a/lib/AccountManager/App.pm b/lib/AccountManager/App.pm
index 2838334463945e2f43559d16869634cc713e5db3..40c3b1549a03f78f1cfd8a14482c0fe6c099cbb5 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 89609686f6d65d22bd1239f36e73ecbac429aa37..ca2a3735bca032e02b91d02d83070913fbd5fc74 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 89609686f6d65d22bd1239f36e73ecbac429aa37..ca2a3735bca032e02b91d02d83070913fbd5fc74 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.") %]