windows 如何判斷對方MAIL主機是否存在

Home Home
引用 | 編輯 月光
2007-05-22 09:29
樓主
推文 x0
複製程式
function get_host($sEmailToSend)    
{   
    $sGatewayIP = ཹ.31.233.1'   
    //$sGatewayIP = 餀.95.1.1'   
  
    preg_match("'\.*@(.*)'sim",$sEmailToSend,$aMatches);   
  
    $sNSLookup = shell_exec("nslookup -q=mx {$aMatches[1]} {$sGatewayIP} ");   
  
    preg_match_all("'^.*MX preference = (\d{1,10}), mail exchanger = (.*)$'simU",$sNSLookup,$aMXMatches);   
  
    if(!emptyempty($aMXMatches[2])){   
        return true;   
    }else{   
    $hosts = gethostbynamel($aMatches[1]);   
    if (is_array($hosts)) {      
       return true;   
    }else{       
       return false;   
    }       
    }      
  
}


獻花 x0