scriptingBlog.com - For those who work online
Do you have something interesting to share with others? If you do, click here to write a post or a press-release to the blog. All 100% free!

Validate Email Address

This is a very simple function that can be used to validate eMail addresses. The function verifies whether a given eMail address matches a regular expression that eMail addresses should conform and validate the eMail address host.

Source code:


<?
function check_email($email){
   if(@ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$"$email)){

       $url substr(strrchr($email"@"), 1);
       if (strstr($url"/")) {
           $url explode("/"$url2);
           $url[1] = "/".$url[1];
       } else {
           $url = array($url"/");
       }
       $fh = @fsockopen($url[0], 80);
       if ($fh) {
           @fputs($fh,"GET ".$url[1]." HTTP/1.1\nHost:".$url[0]."\n\n");
           if (@fread($fh22) == "HTTP/1.1 404 Not Found") { return FALSE; }
           else { return TRUE;    }
       } else { return FALSE;}
   }else{
       return FALSE;
   }
}
?>

Tags: , ,

Leave a Reply