aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdmund von der Burg <evdb@mysociety.org>2011-03-03 09:05:44 +0000
committerEdmund von der Burg <evdb@mysociety.org>2011-03-03 09:05:44 +0000
commitc47cfe2bdd85b1561b57a5bccad9a1512af1f1bb (patch)
tree92286ee54a8485855cd935751a515542aaa5690e
parent20fe27a76cd5ba8d912024f40c6ea881791623b0 (diff)
Check that UTF8 in emails works
-rw-r--r--perllib/FixMyStreet/App.pm3
-rw-r--r--perllib/FixMyStreet/App/View/Email.pm1
-rw-r--r--perllib/FixMyStreet/App/View/Web.pm1
-rw-r--r--t/app/helpers/send_email.t4
-rw-r--r--templates/email/default/test2
5 files changed, 11 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm
index f5d2f7d62..3e3c9c8a8 100644
--- a/perllib/FixMyStreet/App.pm
+++ b/perllib/FixMyStreet/App.pm
@@ -184,6 +184,9 @@ sub send_email {
$email->header_set( ucfirst($_), $vars->{$_} )
for grep { $vars->{$_} } qw( to from subject);
+ # always send utf8 emails
+ $email->header_set( 'Content-Type' => 'text/plain; charset="utf-8"' );
+
# send the email
$c->model('EmailSend')->send($email);
diff --git a/perllib/FixMyStreet/App/View/Email.pm b/perllib/FixMyStreet/App/View/Email.pm
index 646615d36..fa46623eb 100644
--- a/perllib/FixMyStreet/App/View/Email.pm
+++ b/perllib/FixMyStreet/App/View/Email.pm
@@ -12,6 +12,7 @@ __PACKAGE__->config(
INCLUDE_PATH => [ #
FixMyStreet->path_to( 'templates', 'email', 'default' ),
],
+ ENCODING => 'utf8',
render_die => 1,
expose_methods => ['loc'],
);
diff --git a/perllib/FixMyStreet/App/View/Web.pm b/perllib/FixMyStreet/App/View/Web.pm
index 1c6d73ca7..9c16e0d84 100644
--- a/perllib/FixMyStreet/App/View/Web.pm
+++ b/perllib/FixMyStreet/App/View/Web.pm
@@ -12,6 +12,7 @@ __PACKAGE__->config(
INCLUDE_PATH => [ #
FixMyStreet->path_to( 'templates', 'web', 'default' ),
],
+ ENCODING => 'utf8',
render_die => 1,
expose_methods => ['loc'],
);
diff --git a/t/app/helpers/send_email.t b/t/app/helpers/send_email.t
index 6a7d77c0b..a44ddb01c 100644
--- a/t/app/helpers/send_email.t
+++ b/t/app/helpers/send_email.t
@@ -2,6 +2,7 @@
use strict;
use warnings;
+use utf8;
BEGIN {
use FixMyStreet;
@@ -37,11 +38,14 @@ is $emails[0]->as_string, << 'END_OF_BODY', "email is as expected";
Subject: test email
From: evdb@ecclestoad.co.uk
To: test@recipient.com
+Content-Type: text/plain; charset="utf-8"
Hello,
This is a test email where foo: bar.
+utf8: 我们应该能够无缝处理UTF8编码
+
Yours,
FixMyStreet.
END_OF_BODY
diff --git a/templates/email/default/test b/templates/email/default/test
index 0a751dac2..2d52e7f31 100644
--- a/templates/email/default/test
+++ b/templates/email/default/test
@@ -5,5 +5,7 @@ Hello,
This is a test email where foo: [% foo %].
+utf8: 我们应该能够无缝处理UTF8编码
+
Yours,
FixMyStreet.