From a28e0f014d025c30737ae4368e595e70b84cf847 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 1 Mar 2011 13:42:21 -0300 Subject: [PATCH] setFrom using _setEmail. DRY and consistence. --- lib/Cake/Network/CakeEmail.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Network/CakeEmail.php b/lib/Cake/Network/CakeEmail.php index d7b57d707..daf689fd8 100644 --- a/lib/Cake/Network/CakeEmail.php +++ b/lib/Cake/Network/CakeEmail.php @@ -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.')); } }