From fd0fc046b0354bb23a4f90fa7603b52be89eba6a Mon Sep 17 00:00:00 2001 From: Rogov Viktor Date: Wed, 4 Mar 2015 09:30:55 +0600 Subject: [PATCH] Another try to catch timeouts --- src/Smtp.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Smtp.php b/src/Smtp.php index bc0fd9c..6f41999 100644 --- a/src/Smtp.php +++ b/src/Smtp.php @@ -161,13 +161,18 @@ protected function _readResponse($expected, $prevException = null) if (substr($response, 0, 3) != $expected) { $type = gettype($response); + $msg = "Unexpected response {$type}:'{$response}'. "; if (feof($this->_smtp)) { $this->close(); - $eof = 'EOF - true'; + $msg .= 'EOF - true. '; } else { - $eof = 'EOF - false'; + $msg .= 'EOF - false. '; + if ($response == '') { + $msg .= 'Timeout? Reconnecting. '; + $this->close(); + } } - $msg = "Unexpected response {$type}:'{$response}'. {$eof}. Expected {$expected}. Here is the dialog dump:\n{$this->_log}"; + $msg .= "Expected {$expected}. Here is the dialog dump:\n{$this->_log}"; throw new Exception($msg, 0, $prevException); }