Skip to content

Latest commit

 

History

History
54 lines (39 loc) · 1.4 KB

File metadata and controls

54 lines (39 loc) · 1.4 KB

Getting Started

Installation

composer require monadial/spamc-client

Requirements

  • PHP 8.2 or higher
  • A running SpamAssassin spamd instance

Basic Usage

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()}";
}

Structured Results

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)
}

Next Steps