• <label id="pxtpz"><meter id="pxtpz"></meter></label>
      1. <span id="pxtpz"><optgroup id="pxtpz"></optgroup></span>

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

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

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

        更新時間:2022-04-27 文章作者:未知 信息來源:網(wǎng)絡 閱讀次數(shù):

        一般我們常希望拜訪你的網(wǎng)站的朋友能留下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 "無效";  

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

        本類教程下載

        系統(tǒng)下載排行

        主站蜘蛛池模板: 亚洲人成亚洲精品| 亚洲av无码乱码国产精品| 日韩亚洲产在线观看| 最近免费中文字幕大全免费 | 久久这里只精品国产免费10| 国产精品xxxx国产喷水亚洲国产精品无码久久一区 | 亚洲免费视频网站| 99久久99久久精品免费观看| 亚洲日韩乱码中文无码蜜桃| 老司机在线免费视频| 亚洲国产精品精华液| 国产免费啪嗒啪嗒视频看看| 无忧传媒视频免费观看入口| 亚洲综合无码精品一区二区三区 | 亚洲av无码国产精品夜色午夜| 无码人妻一区二区三区免费n鬼沢| 亚洲美女视频免费| 岛国av无码免费无禁网站| 亚洲欧美在线x视频| 国产偷窥女洗浴在线观看亚洲| 两个人看的www免费视频| 亚洲短视频在线观看| 成人性生免费视频| 无码免费又爽又高潮喷水的视频 | 99爱视频99爱在线观看免费| 亚洲综合国产成人丁香五月激情| 免费国产在线观看| 久久免费动漫品精老司机| 精品亚洲成在人线AV无码| 免费国产成人午夜电影| 久久精品国产免费| 亚洲女女女同性video| 国产亚洲精品拍拍拍拍拍| 亚洲视频免费观看| 亚洲AV无码一区二区一二区| 亚洲高清国产AV拍精品青青草原| 午夜福利不卡片在线播放免费| 美女被爆羞羞网站免费| 老色鬼久久亚洲AV综合| 国产一区视频在线免费观看| 日韩精品免费在线视频|