Home > PHP > Spam Filters

Spam Filters

To avoid unnecessary mails forwading to the admin End.

Ways to achieve,

1. We can check the content(body) of the email — whether any http:// exists other than our site links

2. Captcha can be used

3. We can check the domain name exists or not

Eg:  checkdnsrr Check DNS records corresponding to a given Internet host name or IP address

<?php

//This will not work

if(checkdnsrr(“round-robin-example.com”),“ALL”)) {

return true;

} else {

return false;

}

//But every value other than “ANY” will work

if(checkdnsrr(“round-robin-example.com”),“A”)){

return true;

}else{

return false;

}

?>

checkdnsrr will not work in windows – way to achieve,

<?php

// Reference link – http://www.sitepoint.com/users-email-address-php/

// checkdnsrr() support for Windows by HM2K <php [spat] hm2k.org>

function win_checkdnsrr($host, $type=‘MX’) {

if (strtoupper(substr(PHP_OS, 0, 3)) != ‘WIN’) { return; }

if (empty($host)) { return; }

$types=array(‘A’, ‘MX’, ‘NS’, ‘SOA’, ‘PTR’, ‘CNAME’, ‘AAAA’, ‘A6’, ‘SRV’, ‘NAPTR’, ‘TXT’, ‘ANY’);

if (!in_array($type,$types)) {

user_error(“checkdnsrr() Type ‘$type’ not supported”, E_USER_WARNING);

return;

}

@exec(‘nslookup -type=’.$type.‘ ‘.escapeshellcmd($host), $output);

foreach($output as $line){

if (preg_match(‘/^’.$host.‘/’,$line)) { return true; }

}

}

// Define

if (!function_exists(‘checkdnsrr’)) {

function checkdnsrr($host, $type=‘MX’) {

return win_checkdnsrr($host, $type);

}

}

/* example */

echo “<pre>”;

$domains=array(‘example.com’,‘php.net’);

foreach ($domains as $domain) {

$result=checkdnsrr($domain);

echo $domain.‘:’;

echo $result?“true\n”:“false\n”;

}

?>

Advertisements
Categories: PHP
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: