From e02cb81a6707332bf01d8268a0073ae47d8c228f Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 29 May 2010 12:04:29 -0300 Subject: [PATCH] Reading a smtp response until EOL. Fixes #378 --- cake/libs/controller/components/email.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index d18784abb..5ee9f531f 100755 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -880,7 +880,15 @@ class EmailComponent extends Object{ $this->__smtpConnection->write($data . "\r\n"); } while ($checkCode !== false) { - $response = $this->__smtpConnection->read(); + $response = ''; + $startTime = time(); + while (substr($response, -2) !== "\r\n" && ((time() - $startTime) < $this->smtpOptions['timeout'])) { + $response .= $this->__smtpConnection->read(); + } + if (substr($response, -2) === "\r\n") { + $this->smtpError = 'timeout'; + return false; + } $response = end(explode("\r\n", rtrim($response, "\r\n"))); if (preg_match('/^(' . $checkCode . ')(.)/', $response, $code)) {