加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php检测邮箱地址是否存在

发布时间:2020-12-13 20:27:05 所属栏目:PHP教程 来源:网络整理
导读:在php中有这么一个函数checkdnsrr来验证dns是否可访问来检测邮箱地址是否存在,php实例代码如下: $email = abc@phpfensi.com ; $check_email = checkdnsrr ( $email , a ); if ( $check_email ){ return true; } else { return false; } 关于checkdnsrr函数详

在php中有这么一个函数checkdnsrr来验证dns是否可访问来检测邮箱地址是否存在,php实例代码如下:

  1. $email ="abc@phpfensi.com"
  2. $check_email = checkdnsrr($email,"a"); 
  3. if($check_email) { 
  4. return true; 
  5. else { 
  6. return false; 

关于checkdnsrr函数详细说明:

bool checkdnsrr(string $host[,string $type = "mx"])

checkdnsrr.检查指定网址的dns记录.

PHP实例代码如下:

  1. //this will not work 
  2. if(checkdnsrr("round-robin-example.com"),"all")){ 
  3.      return true; 
  4. }else
  5.      return false; 
  6. //but every value other than "any" will work 
  7. if(checkdnsrr("round-robin-example.com"),"a")){ 
  8.      return true; 
  9. }else
  10.      return false; 

指定的参数 host 可以是网络位址(ip address),也可以用机器名称(domain name),参数 type 可以省略,内定值为 mx,而参数 type 的值可为以下的其中之一:a、mx、ns、soa、ptr、cname 或 any,若找到了指定网址的 dns 字段,返回 true;若未找到指定的 dns 字段或是有错误均会返回 false.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读