diff --git a/include/class.mailer.php b/include/class.mailer.php index a469d5528f6598489a8a8ecd63b795594f5db322..482f0196061431551132391cdc2b9513ed4bde6a 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, ));