From 67f2255076c1344aa76d775ea294eebdf3f919af Mon Sep 17 00:00:00 2001 From: TommyO Date: Thu, 29 May 2008 20:43:13 +0000 Subject: [PATCH] Fixed minor bug in connect communications with SMTP server git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7059 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/controller/components/email.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index 3d4ca6870..ff5966070 100644 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -665,9 +665,11 @@ class EmailComponent extends Object{ if (!$this->__smtpConnection->connect()) { $this->smtpError = $this->__smtpConnection->lastError(); return false; + } elseif (!$this->__smtpSend(null, '220')) { + return false; } - - if (!$this->__smtpSend('HELO cake', '220')) { + + if (!$this->__smtpSend('HELO cake', '250')) { return false; } @@ -723,15 +725,16 @@ class EmailComponent extends Object{ * @access private */ function __smtpSend($data, $checkCode = '250') { - $this->__smtpConnection->write($data . "\r\n"); - + if (!is_null($data)) { + $this->__smtpConnection->write($data . "\r\n"); + } if ($checkCode !== false) { - $response = ""; + $response = ''; - while($str = $this->__smtpConnection->read()) { + while ($str = $this->__smtpConnection->read()) { $response .= $str; - if($str{3} == ' ') { + if ($str[3] == ' ') { break; } }