email domain validation in php on windows -
i asking email address through form in website. want validate domain can prevent fake entries getting right now. using following code, dose not seem work :
function mycheckdnsrr($hostname, $rectype = '') { if(!empty($hostname)) { if( $rectype == '' ) $rectype = "mx"; exec("nslookup -type=$rectype $hostname", $result); // check each line find 1 starts host // name. if exists function succeeded. foreach ($result $line) { if(eregi("^$hostname",$line)) { echo "valid email"; } } // otherwise there no mail handler domain echo "invalid email"; } echo "invalid email"; }
i new , used code here
please guide me. thanks.
i guess can ping this.
function mycheckdnsrr($email_address) { if(!empty($email_address)) { $hostname=strstr($email_address, '@'); $hostname=str_replace("@","www.",$hostname); exec("ping " . $hostname, $output, $result); if ($result == 0){ echo "valid email"; } else{ echo "invalid email"; } } }
call
echo mycheckdnsrr("sample@gmail.com");
Comments
Post a Comment