日本国产亚洲-日本国产一区-日本国产一区二区三区-日本韩国欧美一区-日本韩国欧美在线-日本韩国欧美在线观看

當前位置:雨林木風下載站 > 技術開發教程 > 詳細頁面

所有方面測試email的有效果性

所有方面測試email的有效果性

更新時間:2022-04-27 文章作者:未知 信息來源:網絡 閱讀次數:

一般我們常希望拜訪你的網站的朋友能留下Email  
但是很多人都會隨便打,造成管理員的困擾,  
以下這個class可以線上檢查Email是否是有效的Email(存不存在)  

<?  
class CEmail {  
var $email_regular_expression="^([a-z0-9_]|\-|\.)+@(([a-z0-9_]|\-)+\.)+[a-z]{2,4}$";  
var $timeout=0;  
var $localhost="";  
var $localuser="";  

Function GetLine($connection)  
{  
for($line="";;)  
{  
if(feof($connection))  
return(0);  
$line.=fgets($connection,100);  
$length=strlen($line);  
if($length>=2  
&& substr($line,$length-2,2)=="rn")  
return(substr($line,0,$length-2));  
}  
}  

Function PutLine($connection,$line)  
{  
return(fputs($connection,"$linern"));  
}  

Function VerifyRule($email)  
{  
return(eregi($this->email_regular_expression,$email)!=0);  
}  

Function ValidateEmailHost($email,$hosts=0)  
{  
if(!$this->VerifyRule($email))  
return(0);  
$user=strtok($email,"@");  
$domain=strtok("");  
if(GetMXRR($domain,&$hosts,&$weights))  
{  
$mxhosts=array();  
for($host=0;$host<count($hosts);$host++)  
$mxhosts[$weights[$host]]=$hosts[$host];  
KSort($mxhosts);  
for(Reset($mxhosts),$host=0;$host<count($mxhosts);Next($mxhosts),$host++)  
$hosts[$host]=$mxhosts[Key($mxhosts)];  
}  
else  
{  
$hosts=array();  
if(strcmp(@gethostbyname($domain),$domain)!=0)  
$hosts[]=$domain;  
}  
return(count($hosts)!=0);  
}  

Function VerifyResultLines($connection,$code)  
{  
while(($line=$this->GetLine($connection)))  
{  
if(!strcmp(strtok($line," "),$code))  
return(1);  
if(strcmp(strtok($line,"-"),$code))  
return(0);  
}  
return(-1);  
}  

Function VerifyOnline($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<count($hosts);$host++)  
{  
if(($connection=($this->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);  
}  

function Verify($email,$type=0) {  
    if($type==0) return $this->VerifyRule($email) ;  
    else     return $this->VerifyOnline($email) ;  

}  

};      
      
      
?>  


用法:  
$m=new CEmail;  
//僅檢查語法  
if($m->Verify("jerry@mail.jerry.com.tw",0)) echo "有效";  
else echo "無效";  

//線上檢查是否真的有該Email  
if($m->Verify("jerry@mail.jerry.com.tw",1)) echo "有效";  
else echo "無效";  

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

主站蜘蛛池模板: 久久久久国产免费 | 日韩 欧美 亚洲 中文字幕 | 美女被免费网站视频免费 | 国内精品一区二区三区αv 国内精品一区二区三区最新 | 欧美成人激情在线 | 吃女人的奶水和做爰视频 | 中文字幕天天躁日日躁狠狠躁免费 | 天天做天天爱天天爽综合网 | 欧美日韩综合精品一区二区三区 | 欧美拍拍视频 | 四虎永久免费影院 | 久久久久久草 | 国产毛片一级国语版 | 天天插综合 | 国产欧美在线观看一区 | 婷婷色站 | 26uuu在线视频 | 国产实拍会所女技师在线 | 国产免费久久精品 | xxx日本在线观看 | 成人免费视频国产 | 亚洲欧美日韩高清mmm777 | 日本一区二区三区在线 观看网站 | 久久久免费观成人影院 | 亚洲日本va中文字幕久久 | 婷婷亚洲久悠悠色在线播放 | 亚洲欧洲一二三区 | 久久精品中文 | 成人片网址 | 国产青草亚洲香蕉精品久久 | 国产成人一区二区三区在线视频 | 久久99精品久久久久久青青91 | 亚洲美女综合 | 越南高清幻女bbwxxxx | 日韩视频第1页 | 日韩不卡手机视频在线观看 | 欧美视频一区在线观看 | 色婷婷免费视频 | 盗摄偷拍a在线观看 | 亚洲在线日韩 | 久久精品免看国产成 |