mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
setFrom using _setEmail. DRY and consistence.
This commit is contained in:
parent
7aa0d6c1eb
commit
a28e0f014d
1 changed files with 6 additions and 4 deletions
|
@ -205,12 +205,14 @@ class CakeEmail {
|
|||
* @param string $email
|
||||
* @param string $name
|
||||
* @return void
|
||||
* @thrown SocketException
|
||||
*/
|
||||
public function setFrom($email, $name = null) {
|
||||
if ($name !== null) {
|
||||
$this->_from = array($email => $name);
|
||||
} else {
|
||||
$this->_from = array($email => $email);
|
||||
$oldFrom = $this->_from;
|
||||
$this->_setEmail('_from', $email, $name);
|
||||
if (count($this->_from) !== 1) {
|
||||
$this->_from = $oldFrom;
|
||||
throw new SocketException(__('From requires only 1 email address.'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue