Wir würden gern zur Ermittlung des Spamscore die JASON API vom postmarkapp.com verwenden.
In der Datei spamtest_external.php sehen wir dazu keine Möglichkeiten.
Kann die Schnittstelle verwendet werden?
Doku:
https://spamcheck.postmarkapp.com/doc/
PHP-Beispiel:
<?php
....................
$MIME = file_get_contents('spamtest5b46616b971977cac4b71bf62a265eb5');
//$MIME = file_get_contents('spamassassin-test.txt');
$spam_score = get_spam_score($MIME);
if ($spam_score >= 5 OR $spam_score === FALSE)
{ echo "Bitte prüfen Sie die eMail. SpamScore: " . $spam_score;
}
else
{ echo "SpamScore: " . $spam_score;
}
....................
/**
* returns the spam score of a raw email using api from postmarkapp
* @param string $raw_email entire RAW email with headers etc....
* @return numeric/false spam score or FALSE is something went wrong....
*/
function get_spam_score($raw_email)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, '
http://spamcheck.postmarkapp.com/filter');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('email' => $raw_email,'options'=>'short')));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$response = curl_exec($ch);
//something went wrong with the request
if(empty($response) || curl_error($ch) || curl_getinfo($ch, CURLINFO_HTTP_CODE) !== 200)
{ curl_close($ch);
return FALSE;
}
curl_close($ch);
$score = json_decode($response);
if ($score->success == TRUE AND is_numeric($score->score))
return $score->score;
else
return FALSE;
}
?>