Hello everyone, I am a beginner in php. if you have any questions, please check whether the email address actually exists during registration. thank you; environment win32 + php5.45test. phpPHPcode & lt ;? Phpecho & quot; & lt; center & gt; & lt; br/& gt; check whether the email address exists in php.
Hello everyone, I am a beginner in php. if you have any questions, please check whether the email address actually exists during registration. thank you.
Environment win32 + php5.45
Test. php
PHP code
Check whether the email address is correct:
"; Require (" email_validation.php "); $ newmail =" 283285993@qq.com "; $ validator = new email_validation_class; $ validator-> timeout = 10; // if (IsSet ($ newemail) & strcmp ($ newemail, "") {if ($ result = $ validator-> ValidateEmailBox ($ newmail) <0) {echo "is not sure whether your mailbox is correct. is your mailbox too far away from this place?
"; Return;} else {echo" 22222222 "; if (! $ Result) {echo "the email address you entered is incorrect! :)
"; Return;} else {echo" the email address is valid!
";}}?>
Email_validation.php
PHP code
=2 && substr($line,$length-2,2)=="/r/n") return(substr($line,0,$length-2)); } } Function PutLine($connection,$line) { return(fputs($connection,"$line/r/n")); } Function ValidateEmailAddress($email) { //return(eregi($this->email_regular_expression,$email)!=0); //origin://return(eregi("^([a-z0-9_] |//- |//.)+@(([a-z0-9_] |//-)+//.)+[a-z]{2,4}$",$email)!=0); //return preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $_REQUEST[$email]);return preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/", $_REQUEST[$email]);} Function ValidateEmailHost($email,$hosts=0) { if(!$this->ValidateEmailAddress($email)) return(0); $user=strtok($email,"@"); $domain=strtok(""); if(GetMXRR($domain,$hosts,$weights)) { $mxhosts=array(); for($host=0;$host
GetLine($connection))) { if(!strcmp(strtok($line," "),$code)) return(1); if(strcmp(strtok($line,"-"),$code)) return(0); } return(-1); } Function ValidateEmailBox($email) { if(!$this->ValidateEmailHost($email,$hosts)) return(0); if(!strcmp($localhost=$this->localhost,"") && !strcmp($localhost=getenv("SERVER_NAME"),"") && !strcmp($localhost=getenv("HOST"),"")) $localhost="localhost"; if(!strcmp($localuser=$this->localuser,"") && !strcmp($localuser=getenv("USERNAME"),"") && !strcmp($localuser=getenv("USER"),"")) $localuser="root"; for($host=0;$host
timeout ? fsockopen($hosts[$host],25,$errno,$error,$this->timeout) : fsockopen($hosts[$host],25)))) { if($this->VerifyResultLines($connection,"220")>0 && $this->PutLine($connection,"HELO $localhost") && $this->VerifyResultLines($connection,"250")>0 && $this->PutLine($connection,"MAIL FROM: <$localuser@$localhost>") && $this->VerifyResultLines($connection,"250")>0 && $this->PutLine($connection,"RCPT TO: <$email>") && ($result=$this->VerifyResultLines($connection,"250"))>=0) { fclose($connection); return($result); } fclose($connection); } } return(-1); } }; ?>