在php中有這么一個函數checkdnsrr來驗證dns是否可訪問來檢測郵箱地址是否存在,php實例代碼如下:
- $email ="[email protected]";
- $check_email = checkdnsrr($email,"a");
- if($check_email) {
- return true;
- } else {
- return false;
- }
關于checkdnsrr函數詳細說明:
bool checkdnsrr(string $host[,string $type = "mx"])
checkdnsrr.檢查指定網址的dns記錄.
PHP實例代碼如下:
- //this will not work
- if(checkdnsrr("round-robin-example.com"),"all")){
- return true;
- }else{
- return false;
- }
- //but every value other than "any" will work
- if(checkdnsrr("round-robin-example.com"),"a")){
- return true;
- }else{
- return false;
- }
指定的參數 host 可以是網絡位址(ip address),也可以用機器名稱(domain name),參數 type 可以省略,內定值為 mx,而參數 type 的值可為以下的其中之一:a、mx、ns、soa、ptr、cname 或 any,若找到了指定網址的 dns 字段,返回 true;若未找到指定的 dns 字段或是有錯誤均會返回 false.
|
新聞熱點
疑難解答