composer require monadial/spamc-client- PHP 8.2 or higher
- A running SpamAssassin spamd instance
use Monadial\SpamcClient\Client\Client;
// Connect to spamd over TCP (defaults to port 783, 10s timeout)
$client = Client::tcp('localhost');
// Check a message for spam
$response = $client->check($emailMessage);
// Read the results
if ($response->isSpam()) {
echo "This message is spam!";
echo "Score: {$response->getScore()}";
echo "Threshold: {$response->getThreshold()}";
}For more detailed spam check results, use spamResult():
$result = $response->spamResult();
if ($result !== null) {
$result->isSpam; // bool — whether the message is spam
$result->score; // float — SpamAssassin score
$result->threshold; // float — score threshold for spam classification
$result->margin(); // float — distance between score and threshold (positive = spam)
}- Connection Options — TCP, Unix socket, and SSL configuration
- Commands — all available spamd commands
- Training (TELL) — teach SpamAssassin about spam and ham
- Error Handling — exception hierarchy and patterns
- Advanced Usage — custom requests, compression, and protocol details