note 35837 added to function.gethostbyname

From: Date: Tue, 16 Sep 2003 15:11:28 +0000
Subject: note 35837 added to function.gethostbyname
Groups: php.notes 
Request: Send a blank email to php-notes+get-56576@lists.php.net to get a copy of this message
// 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; } } } ---- Manual Page -- http://www.php.net/manual/en/function.gethostbyname.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35837 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35837&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35837&report=yes

« previous php.notes (#56576) next »