From 789911184b72a2765a6faf39652506057350a021 Mon Sep 17 00:00:00 2001 From: Jerome Nadaud Date: Thu, 10 Oct 2013 15:04:32 +0200 Subject: [PATCH] [-] BO : FixBug - Remove second email in recipient --- classes/Mail.php | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/classes/Mail.php b/classes/Mail.php index 910f23494..76ffadc40 100644 --- a/classes/Mail.php +++ b/classes/Mail.php @@ -133,36 +133,46 @@ class MailCore { foreach ($to as $key => $addr) { - $to_name = null; $addr = trim($addr); if (!Validate::isEmail($addr)) { Tools::dieOrLog(Tools::displayError('Error: invalid e-mail address'), $die); return false; } + if (is_array($to_name)) { if ($to_name && is_array($to_name) && Validate::isGenericName($to_name[$key])) $to_name = $to_name[$key]; } - if ($to_name == null) - $to_name = $addr; - /* Encode accentuated chars */ - if (function_exists('mb_encode_mimeheader')) - $to_list->addTo($addr, mb_encode_mimeheader($to_name, 'utf-8')); + + if ($to_name == null || $to_name == $addr) + $to_name = ''; else - $to_list->addTo($addr, self::mimeEncode($to_name)); + { + if (function_exists('mb_encode_mimeheader')) + $to_name = mb_encode_mimeheader($to_name, 'utf-8'); + else + $to_name = self::mimeEncode($to_name); + } + + $to_list->addTo($addr, $to_name); } $to_plugin = $to[0]; } else { /* Simple recipient, one address */ $to_plugin = $to; - if ($to_name == null) - $to_name = $to; - if (function_exists('mb_encode_mimeheader')) - $to_list->addTo($to, mb_encode_mimeheader($to_name, 'utf-8')); + if ($to_name == null || $to_name == $to) + $to_name = ''; else - $to_list->addTo($to, self::mimeEncode($to_name)); + { + if (function_exists('mb_encode_mimeheader')) + $to_name = mb_encode_mimeheader($to_name, 'utf-8'); + else + $to_name = self::mimeEncode($to_name); + } + + $to_list->addTo($to, $to_name); } if(isset($bcc)) { $to_list->addBcc($bcc);