»áÔ±£º ÃÜÂ룺 ¡¡Ãâ·Ñ×¢²á | Íü¼ÇÃÜÂë | »áÔ±µÇ¼ ÍøÒ³¹¦ÄÜ£º ¼ÓÈëÊÕ²Ø ÉèΪÊ×Ò³ ÍøÕ¾ËÑË÷  
 °²È«¼¼Êõ¼¼ÊõÎĵµ
  ¡¤ °²È«ÅäÖÆ
  ¡¤ ¹¤¾ß½éÉÜ
  ¡¤ ºÚ¿Í½Ìѧ
  ¡¤ ·À»ðǽ
  ¡¤ Â©¶´·ÖÎö
  ¡¤ ÆƽâרÌâ
  ¡¤ ºÚ¿Í±à³Ì
  ¡¤ ÈëÇÖ¼ì²â
 °²È«¼¼ÊõÂÛ̳
  ¡¤ °²È«ÅäÖÆ
  ¡¤ ¹¤¾ß½éÉÜ
  ¡¤ ·À»ðǽ
  ¡¤ ºÚ¿ÍÈëÇÖ
  ¡¤ Â©¶´¼ì²â
  ¡¤ Æƽⷽ·¨
  ¡¤ É±¶¾×¨Çø
 °²È«¼¼Êõ¹¤¾ßÏÂÔØ
  ¡¤ É¨Ã蹤¾ß
  ¡¤ ¹¥»÷³ÌÐò
  ¡¤ ºóÃÅľÂí
  ¡¤ ¾Ü¾ø·þÎñ
  ¡¤ ¿ÚÁîÆƽâ
  ¡¤ ´úÀí³ÌÐò
  ¡¤ ·À»ðǽ
  ¡¤ ¼ÓÃܽâÃÜ
  ¡¤ ÈëÇÖ¼ì²â
  ¡¤ ¹¥·ÀÑÝʾ
¼¼ÊõÎĵµ > Web¿ª·¢ > PHP
ÓÃPHPÑéÖ¤ÓÊÏäÊÇ·ñÕæʵÓÐЧ
·¢±íÈÕÆÚ£º2006-02-16 16:36:09×÷ÕߣºÀ ³ö´¦£ºÁ¢»ªÈí¼þÔ°  

Õâ¸ö³ÌÐòÊÇÖ±½ÓÑéÖ¤ÓÊÏäÊÇ·ñÕæʵÓÐЧµÄº¯Êý£¬checkmailÊÇÖ÷º¯Êý£¬Ê¹ÓÃʱÇëÖ±½ÓʹÓü´¿É£¬×¢Ò⣺ÒòʹÓÃÁËDNSº¯Êý£¬¸Ã³ÌÐò²»ÄÜÔËÐÐÔÚWindowsϵͳ֮Ï£¬Ê¹ÓÃLinuxºÍFreeBSD¶¼²âÊÔͨ¹ý¡£

<?
set_time_limit(0);
if($_POST["mail"]!=""){
    echo "µç×ÓÓʼþµØÖ·£º".$_POST["mail"];
    if( checkmail($_POST["mail"]))
        echo " ¡ª <font color=green>ÓÐЧ</font>";
    else
        echo " ¡ª <font color=red>ÎÞЧ</font>";
}
?>

<form method=post action="">
<input type=text name=mail ><input type="submit" value="¼ì²é">
</form>

<?

function server_parse($socket, $response, $line = __LINE__){
    while (substr($server_response, 3, 1) != ' '){
        if (!($server_response = fgets($socket, 512))){
            return false;
        }
    }
    if (!(substr($server_response, 0, 3) == $response)){
        return false;
    }
    return true;
}

function checkmail($strMail){
    $arrMail=explode("@",$strMail);
    if(! getmxrr ( $arrMail[1], $mxhosts ,$bb))return -1;
    if($mxhosts[0]=="")return -1;//²»ÄÜ»ñµÃÖ÷»úµÄMXÐÅÏ¢
    $cc=false;
    for($i=0;$i<count($mxhosts);$i++){
        echo $mxhosts[$i]." ";
        if( $socket = @fsockopen($mxhosts[$i], 25, $errno, $errstr, 5) ){
            if(server_parse($socket, "220", __LINE__)){
                $cc=true;
                break;
            }
        }
    }
    if($cc==false)return -2;//²»ÄÜ´ò¿ªÖ÷»ú
    fputs($socket, "HELO ".$arrMail[1]." ");
    if(!server_parse($socket, "250", __LINE__))return -3;

    srand((double)microtime()*1000000);
    $randval = substr(md5(uniqid(rand())),0,6);
    fputs($socket, "MAIL FROM:<$randval@testemail.com> ");
    //ʹÓÃÊÇÇ뽫testemail.com¸Ä³ÉÄãÍøÕ¾µÄÓòÃû
    if(!server_parse($socket, "250", __LINE__))return -4;

    fputs($socket, "RCPT TO:<$strMail> ");
    if(!server_parse($socket, "250", __LINE__))return -5;//ÎÞЧµÄÓû§Ãû

    fclose($socket);
    return true;
}
?>

¡¾·µ»Ø¶¥²¿¡¿ ¡¾´òÓ¡±¾Ò³¡¿ ¡¾¹Ø±Õ´°¿Ú¡¿

¹ØÓÚÎÒÃÇ / ¸øÎÒÁôÑÔ / °æȨ¾Ù±¨ / Òâ¼û½¨Òé / ÍøÕ¾±à³ÌQQȺ   
Copyright ©2003- 2024 Lihuasoft.net webmaster(at)lihuasoft.net ¼ÓÔØʱ¼ä 0.00135