CkPerl Requires Chilkat v11.0.0+
CkPerl
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 CkPerl Downloads
use chilkat();
$success = 0;
# Assumes Chilkat is unlocked. See Global Unlock Sample.
$email = chilkat::CkEmail->new();
$email->put_From('Workshop team <events@example.com>');
$success = $email->AddTo("Alex Rivera",'alex@example.net');
if ($success != 1) {
print $email->lastErrorText() . "\r\n";
exit;
}
$email->put_Subject("Workshop registration");
$email->put_Body("Your workshop registration is confirmed.");
$request = chilkat::CkJsonObject->new();
$request->UpdateString("email",$email->getMime());
$request->UpdateString("options","short");
$http = chilkat::CkHttp->new();
$http->put_RequireSslCertVerify(1);
$resp = chilkat::CkHttpResponse->new();
$success = $http->HttpJson("POST","https://spamcheck.postmarkapp.com/filter",$request,"application/json",$resp);
if (($success != 1) or ($resp->get_StatusCode() != 200)) {
print "SpamCheck request failed. HTTP " . $resp->get_StatusCode() . "\r\n";
exit;
}
$result = chilkat::CkJsonObject->new();
$success = $result->Load($resp->bodyStr());
if ($success != 1) {
print $result->lastErrorText() . "\r\n";
exit;
}
if ($result->BoolOf("success") != 1) {
print $result->stringOf("message") . "\r\n";
exit;
}
print "SpamAssassin score: " . $result->stringOf("score") . "\r\n";