note 35837 deleted from function.gethostbyname by didou

From: Date: Fri, 27 Feb 2004 15:58:04 +0000
Subject: note 35837 deleted from function.gethostbyname by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-65892@lists.php.net to get a copy of this message
Note Submitter: cwilliams@aerospace.state.al.us ---- // Author: Chris Williams // Date: 9/16/03 // Description: This function takes a scalar value as an argument, // validates it with a reg exp, then sees if the domain exists // Usage: $var = checkEmail($var); function checkEmail($Email) { //Debug or not? $debug = 0; //Do the basic Reg Exp Matching for simple validation if (eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $Email)) { return FALSE; } //split the Email Up for Server validation list($Username, $Domain) = split("@",$Email); //If you get an mx record then this is a valid email domain if(getmxrr($Domain, $MXHost)) { return TRUE; if($debug == 1) { echo "$Domain<BR>getmxrr worked."; } } else { //else use the domain given to try and connect on port 25 //if you can connect then it's a valid domain and that's good enough if(checkdnsrr($Domain.'.', "A")) { $ip = gethostbyname($Domain); //This is to counteract the effects of the Verisign .com .net unregistered email grab if($ip == "64.94.110.11") { if($debug == 1) { echo "$Domain<BR>is invalid. Verisign returned."; } return FALSE; } else { if($debug == 1) { echo "$Domain<BR>fsockopen worked. Verisign wasn't the IP."; } return TRUE; } } else { return FALSE; } } }

« previous php.notes (#65892) next »