diff --git a/class.simple_mail.php b/class.simple_mail.php index bb37f90..3ae1097 100755 --- a/class.simple_mail.php +++ b/class.simple_mail.php @@ -317,15 +317,12 @@ public function addMailHeaders($header, array $pairs) 'You must pass at least one name => email pair.' ); } + $addresses = array(); foreach ($pairs as $name => $email) { - if (is_numeric($name)) { - $addresses[] = $this->formatHeader($email); - } else { - $addresses[] = $this->formatHeader($email, $name); - } + $name = is_numeric($name) ? null : $name; + $addresses[] = $this->formatHeader($email, $name); } - $addresses = implode(',', $addresses); - $this->addGenericHeader($header, $addresses); + $this->addGenericHeader($header, implode(',', $addresses)); return $this; }