PHP ActiveX Requires Chilkat v11.0.0+
PHP ActiveX
Request a SpamAssassin score for a sample email
See more Email Object Examples
Submit a synthetic message to Postmark’s SpamCheck endpoint. The service receives the complete MIME you provide. Request a short result and check both the HTTP status and the API success field before reading the numeric score. SpamCheck API documentation.
Chilkat PHP ActiveX Downloads
<?php
$success = 0;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
$email = new COM("Chilkat.Email");
$email->From = 'Workshop team <events@example.com>';
$success = $email->AddTo('Alex Rivera','alex@example.net');
if ($success != 1) {
print $email->LastErrorText . "\n";
exit;
}
$email->Subject = 'Workshop registration';
$email->Body = 'Your workshop registration is confirmed.';
$request = new COM("Chilkat.JsonObject");
$request->UpdateString('email',$email->getMime());
$request->UpdateString('options','short');
$http = new COM("Chilkat.Http");
$http->RequireSslCertVerify = 1;
$resp = new COM("Chilkat.HttpResponse");
$success = $http->HttpJson('POST','https://spamcheck.postmarkapp.com/filter',$request,'application/json',$resp);
if (($success != 1) or ($resp->StatusCode != 200)) {
print 'SpamCheck request failed. HTTP ' . $resp->StatusCode . "\n";
exit;
}
$result = new COM("Chilkat.JsonObject");
$success = $result->Load($resp->BodyStr);
if ($success != 1) {
print $result->LastErrorText . "\n";
exit;
}
if ($result->BoolOf('success') != 1) {
print $result->stringOf('message') . "\n";
exit;
}
print 'SpamAssassin score: ' . $result->stringOf('score') . "\n";
?>