Skip to content

Commit

Permalink
Refactor the addMailHeaders method
Browse files Browse the repository at this point in the history
  • Loading branch information
Eoghan O'Brien committed Feb 17, 2017
1 parent b826dc9 commit 0fd0eb6
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions class.simple_mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 0fd0eb6

Please sign in to comment.