From fc3101760fb92e5abc64babc8d0d8e1fee2b8b87 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Fri, 17 Dec 2010 00:15:01 +0000 Subject: [PATCH] ENHANCEMENT Always encode email subject as UTF-8 (thanks syntax!) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@115151 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- email/Mailer.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/email/Mailer.php b/email/Mailer.php index d3df7ad72..350564273 100644 --- a/email/Mailer.php +++ b/email/Mailer.php @@ -50,7 +50,6 @@ function htmlEmail($to, $from, $subject, $htmlContent, $attachedFiles = false, $ } - $subjectIsUnicode = (strpos($subject,"&#") !== false); $bodyIsUnicode = (strpos($htmlContent,"&#") !== false); $plainEncoding = ""; @@ -64,9 +63,7 @@ function htmlEmail($to, $from, $subject, $htmlContent, $attachedFiles = false, $ // If the subject line contains extended characters, we must encode the $subject = Convert::xml2raw($subject); - if(isset($subjectIsUnicode) && $subjectIsUnicode) - $subject = "=?UTF-8?B?" . base64_encode($subject) . "?="; - + $subject = "=?UTF-8?B?" . base64_encode($subject) . "?="; // Make the plain text part $headers["Content-Type"] = "text/plain; charset=\"utf-8\""; @@ -170,7 +167,6 @@ function htmlEmail($to, $from, $subject, $htmlContent, $attachedFiles = false, $ * Send a plain text e-mail */ function plaintextEmail($to, $from, $subject, $plainContent, $attachedFiles, $customheaders = false) { - $subjectIsUnicode = false; $plainEncoding = false; // Not ensurely where this is supposed to be set, but defined it false for now to remove php notices if ($customheaders && is_array($customheaders) == false) { @@ -178,13 +174,9 @@ function plaintextEmail($to, $from, $subject, $plainContent, $attachedFiles, $cu dieprintr($headers); } - if(strpos($subject,"&#") !== false) $subjectIsUnicode = true; - // If the subject line contains extended characters, we must encode it $subject = Convert::xml2raw($subject); - if($subjectIsUnicode) - $subject = "=?UTF-8?B?" . base64_encode($subject) . "?="; - + $subject = "=?UTF-8?B?" . base64_encode($subject) . "?="; // Make the plain text part $headers["Content-Type"] = "text/plain; charset=\"utf-8\"";