We used to make use of the standard SPAM filtering code developed internally at Techwyse Intl.
Instead we can now make use of the standard AKISMET API classes which in turn would gauarantee better results I presume as it's already a well know SPAM filtering routine.
The code can be implemented in the following manner.
Step 1: Download class.microakismet.inc.php and include that in your mail action script.
Step 2: Generate the API key for the client from Akismet website and this needs to be mentioned in the following code snippet
$akey='<akismet key>';
$apage= '<CORRESPONDING PAGE NAME>';
$aver='askapache.com/1.0';
$akismet = new MicroAkismet( $akey, $apage, $aver );
Step 3: Then we need to populate the array variable that gets sent to Akismet server for SPAM checking as follows
//data to Akismet
$vars = array();
foreach(array_keys($_SERVER) as $skey){
if((substr($skey, 0, 5) == "HTTP_") && !empty($_SERVER[$skey]))
$vars[str_replace('HTTP_','',$skey)]=$_SERVER[$skey];
}
$vars["user_ip"] = $_SERVER["REMOTE_ADDR"];
$vars["user_agent"] = $_SERVER["HTTP_USER_AGENT"];
$vars["comment_content"] = $_POST["comments"];
$vars["comment_author"] = $_POST["fname"];
$vars["comment_author_email"] = $_POST["email"];
$vars["comment_type"] = 'comment';
$vars['permalink'] = '<DOMAIN NAME>'.$_SERVER['REQUEST_URI'];
$vars['referrer'] = $_SERVER['HTTP_REFERER'];
$vars['phone_number'] = $_POST['phoneno'];
$vars['organization'] = '';
Step 4: Now invoke the AKISMET class spam check method and do the needful
if($akismet->check( $vars ))
{
//Redirect to index page
}
else
{
//Mail sending script
}
We have implemented this for one of our clients and seems like it's working fine. Cheers to our little buddies at AKISMET for providing the API
