From d3404b02eb87108d269628cd9c5d4b425239a73b Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Mon, 22 Oct 2012 15:13:45 -0400 Subject: [PATCH] Make sure subject & FROM name are UTF-8 encoded --- include/class.mailer.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/include/class.mailer.php b/include/class.mailer.php index a469d5528..482f01960 100644 --- a/include/class.mailer.php +++ b/include/class.mailer.php @@ -65,8 +65,8 @@ class Mailer { function getFromAddress() { - if(!$this->ht['from'] && $this->getEmail()) - $this->ht['from'] =$this->getEmail()->getAddress(); + if(!$this->ht['from'] && ($email=$this->getEmail())) + $this->ht['from'] =sprintf('"%s" <%s>', $this->str_utf8($email->getName()?$email->getName():$email->getEmail()), $email->getEmail()); return $this->ht['from']; } @@ -84,6 +84,12 @@ class Mailer { $this->attachments = array_merge($this->attachments, $attachments); } + /* utils */ + + function str_utf8($text) { + return "=?utf-8?b?".base64_encode($text)."?="; + } + function send($to, $subject, $message, $options=null) { global $ost; @@ -103,7 +109,7 @@ class Mailer { $headers = array ( 'From' => $this->getFromAddress(), 'To' => $to, - 'Subject' => $subject, + 'Subject' => $this->str_utf8($subject), 'Date'=> date('D, d M Y H:i:s O'), 'Message-ID' => $messageId, 'X-Mailer' =>'osTicket Mailer', @@ -142,7 +148,7 @@ class Mailer { 'auth' => $smtp['auth'], 'username' => $smtp['username'], 'password' => $smtp['password'], - 'timeout' =>20, + 'timeout' => 20, 'debug' => false, )); -- GitLab