PDA

View Full Version : SpamAssasin integration


briksoftware
02-19-2008, 08:00 AM
I added a couple of functions to class.mailparse.php to parse the SpamAssasin boolean flag. You can then use this in pipe.php to do something different than usual (like dropping them) with mails tagged as spam.

function isSpam() {
return Mail_Parse::parseSpamAssasinFlag($this->getHeader());
}

function parseSpamAssasinFlag($header=null) {
$spam = false;

if($header) {
$spam = (strpos($header,'X-Spam-Flag: YES') !== false);
}

return $spam;
}

briksoftware
02-20-2008, 02:09 PM
I added the following lines to pipe.php just after the Mail_Parse object is created. Then with a cron job you can get your daily spam digest mailed to you.


// Is it spam? If so we log to spamlog and quit
if($parser->isSpam()) {
$spamlog = fopen("spamlog", 'a');
fwrite($spamlog, $data);
fclose($spamlog);
api_exit(EX_SUCCESS);
}