From 5b23f0e135ab3eadf51263ac703fdbb55f12e370 Mon Sep 17 00:00:00 2001 From: ftimme <ft@falkotimme.com> Date: Wed, 26 Jun 2013 09:31:46 -0400 Subject: [PATCH] - Added translations for website backup options. --- interface/lib/classes/ispcmail.inc.php | 55 ++++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 42 insertions(+), 13 deletions(-) diff --git a/interface/lib/classes/ispcmail.inc.php b/interface/lib/classes/ispcmail.inc.php index 388a638..e9534ec 100644 --- a/interface/lib/classes/ispcmail.inc.php +++ b/interface/lib/classes/ispcmail.inc.php @@ -414,16 +414,22 @@ $this->body = "This is a multi-part message in MIME format.\n\n"; if($text) { - $this->body .= "--{$this->mime_boundary}\n" . + /*$this->body .= "--{$this->mime_boundary}\n" . "Content-Type:text/plain; charset=\"" . strtolower($this->mail_charset) . "\"\n" . - "Content-Transfer-Encoding: 7bit\n\n" . $this->text_part . "\n\n"; - } + "Content-Transfer-Encoding: 7bit\n\n" . $this->text_part . "\n\n";*/ + $this->body .= "--{$this->mime_boundary}\n" . + "Content-Type:text/plain; charset=\"UTF-8\"\n" . + "Content-Transfer-Encoding: 8bit\n\n" . $this->text_part . "\n\n"; + } if($html) { - $this->body .= "--{$this->mime_boundary}\n" . + /*$this->body .= "--{$this->mime_boundary}\n" . "Content-Type:text/html; charset=\"" . strtolower($this->mail_charset) . "\"\n" . - "Content-Transfer-Encoding: 7bit\n\n" . $this->html_part . "\n\n"; - } + "Content-Transfer-Encoding: 7bit\n\n" . $this->html_part . "\n\n";*/ + $this->body .= "--{$this->mime_boundary}\n" . + "Content-Type:text/html; charset=\"UTF-8\"\n" . + "Content-Transfer-Encoding: 8bit\n\n" . $this->html_part . "\n\n"; + } if($attach) { foreach($this->attachments as $att) { @@ -496,11 +502,32 @@ * @access private */ private function _encodeHeader($input, $charset = 'ISO-8859-1') { - preg_match_all('/(\s?\w*[\x80-\xFF]+\w*\s?)/', $input, $matches); - foreach ($matches[1] as $value) { - $replacement = preg_replace('/([\x20\x80-\xFF])/e', '"=" . strtoupper(dechex(ord("\1")))', $value); - $input = str_replace($value, '=?' . $charset . '?Q?' . $replacement . '?=', $input); - } + preg_match_all('/(\s?\w*[\x80-\xFF]+\w*\s?)/', $input, $matches); + foreach ($matches[1] as $value) { + $replacement = preg_replace('/([\x20\x80-\xFF])/e', '"=" . strtoupper(dechex(ord("\1")))', $value); + $input = str_replace($value, '=?' . $charset . '?Q?' . $replacement . '?=', $input); + } + + return $input; + } + + /** + * Function to encode the subject if necessary + * according to RFC2047 + * @access private + */ + private function _encodeSubject($input, $charset = 'ISO-8859-1') { + /* + if($charset == 'UTF-8' && function_exists('imap_8bit')) { + $input = "=?utf-8?Q?" . imap_8bit($input) . "?="; + } else { + preg_match_all('/(\s?\w*[\x80-\xFF]+\w*\s?)/', $input, $matches); + foreach ($matches[1] as $value) { + $replacement = preg_replace('/([\x20\x80-\xFF])/e', '"=" . strtoupper(dechex(ord("\1")))', $value); + $input = str_replace($value, '=?' . $charset . '?Q?' . $replacement . '?=', $input); + } + }*/ + $input='=?UTF-8?B?'.base64_encode($input).'?='; return $input; } @@ -578,7 +605,8 @@ //$subject = $this->_encodeHeader($this->headers['Subject'], $this->mail_charset); $subject = $this->headers['Subject']; - $enc_subject = $this->_encodeHeader($subject, $this->mail_charset); + //$enc_subject = $this->_encodeHeader($subject, $this->mail_charset); + $enc_subject = $this->_encodeSubject($subject, $this->mail_charset); unset($this->headers['Subject']); } @@ -652,7 +680,8 @@ else $rec_string .= $recip; } $to = $this->_encodeHeader($rec_string, $this->mail_charset); - $result = mail($to, $subject, $this->body, implode($this->_crlf, $headers)); + //$result = mail($to, $subject, $this->body, implode($this->_crlf, $headers)); + $result = mail($to, $enc_subject, $this->body, implode($this->_crlf, $headers)); } // Reset the subject in case mail is resent -- Gitblit v1.9.1