Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/Spamassassin/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ protected function write($socket, $data)
* @param resource $socket Socket connection created by getSocket()
*
* @return array Array containing output headers and message
* @throws \Exception In case the server goes away
*/
protected function read($socket)
{
Expand All @@ -150,6 +151,9 @@ protected function read($socket)

while (true) {
$buffer = fgets($socket, 128);
if($buffer === false) {
throw new \Exception('No response from SpamAssassin Server');
}
$headers .= $buffer;
if ($buffer == "\r\n" || feof($socket)) {
break;
Expand All @@ -158,6 +162,9 @@ protected function read($socket)

while (!feof($socket)) {
$message .= fgets($socket, 128);
if($message === false) {
throw new \Exception('No response from SpamAssassin Server');
}
}

fclose($socket);
Expand Down Expand Up @@ -261,7 +268,7 @@ protected function parseOutput($header, $message)

/**
* Pings the server to check the connection
*
*
* @return bool
*/
public function ping()
Expand All @@ -282,7 +289,7 @@ public function ping()
* Returns a detailed report if the message is spam or null if it's ham
*
* @param string $message Email message
*
*
* @return Result Detailed spam report
*/
public function getSpamReport($message)
Expand Down Expand Up @@ -416,9 +423,9 @@ public function learn($message, $learnType = self::LEARN_SPAM)

/**
* Report message as spam, both local and remote.
*
*
* @param string $message Raw email message
*
*
* @return bool
*/
public function report($message)
Expand All @@ -433,9 +440,9 @@ public function report($message)

/**
* Revokes a message previously reported as spam.
*
*
* @param string $message Raw email message
*
*
* @return bool
*/
public function revoke($message)
Expand Down