diff --git a/lib/classes/Swift/Transport/AbstractSmtpTransport.php b/lib/classes/Swift/Transport/AbstractSmtpTransport.php index 39b6e2135..fa1edd533 100644 --- a/lib/classes/Swift/Transport/AbstractSmtpTransport.php +++ b/lib/classes/Swift/Transport/AbstractSmtpTransport.php @@ -443,6 +443,10 @@ protected function throwException(Swift_TransportException $e) /** Throws an Exception if a response code is incorrect */ protected function assertResponseCode($response, $wanted) { + if (!$response) { + $this->throwException(new Swift_TransportException('Expected response code '.implode('/', $wanted).' but got an empty response')); + } + list($code) = sscanf($response, '%3d'); $valid = (empty($wanted) || in_array($code, $wanted)); @@ -452,12 +456,7 @@ protected function assertResponseCode($response, $wanted) } if (!$valid) { - $this->throwException( - new Swift_TransportException( - 'Expected response code '.implode('/', $wanted).' but got code '. - '"'.$code.'", with message "'.$response.'"', - $code) - ); + $this->throwException(new Swift_TransportException('Expected response code '.implode('/', $wanted).' but got code "'.$code.'", with message "'.$response.'"', $code)); } }