[-] BO : FixBug message charset problem in mail

This commit is contained in:
Jerome Nadaud
2013-08-07 16:40:40 +02:00
parent de3b121b11
commit 44f7356d44
+6 -3
View File
@@ -52,7 +52,8 @@ class MailCore
* @param bool $die * @param bool $die
*/ */
public static function Send($id_lang, $template, $subject, $template_vars, $to, public static function Send($id_lang, $template, $subject, $template_vars, $to,
$to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null, $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null) $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null,
$template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null)
{ {
$configuration = Configuration::getMultiple(array( $configuration = Configuration::getMultiple(array(
'PS_SHOP_EMAIL', 'PS_SHOP_EMAIL',
@@ -146,7 +147,7 @@ class MailCore
if ($to_name == null) if ($to_name == null)
$to_name = $addr; $to_name = $addr;
/* Encode accentuated chars */ /* Encode accentuated chars */
$to_list->addTo($addr, '=?UTF-8?B?'.base64_encode($to_name).'?='); $to_list->addTo($addr, mb_encode_mimeheader($to_name, 'utf-8'));
} }
$to_plugin = $to[0]; $to_plugin = $to[0];
$to = $to_list; $to = $to_list;
@@ -155,7 +156,7 @@ class MailCore
$to_plugin = $to; $to_plugin = $to;
if ($to_name == null) if ($to_name == null)
$to_name = $to; $to_name = $to;
$to = new Swift_Address($to, '=?UTF-8?B?'.base64_encode($to_name).'?='); $to = new Swift_Address($to, mb_encode_mimeheader($to_name, 'utf-8'));
} }
try { try {
/* Connect with the appropriate configuration */ /* Connect with the appropriate configuration */
@@ -230,6 +231,8 @@ class MailCore
/* Create mail and attach differents parts */ /* Create mail and attach differents parts */
$message = new Swift_Message('['.Configuration::get('PS_SHOP_NAME', null, null, $id_shop).'] '.$subject); $message = new Swift_Message('['.Configuration::get('PS_SHOP_NAME', null, null, $id_shop).'] '.$subject);
$message->setCharset('utf-8');
/* Set Message-ID - getmypid() is blocked on some hosting */ /* Set Message-ID - getmypid() is blocked on some hosting */
$message->setId(Mail::generateId()); $message->setId(Mail::generateId());