当前位置:首页 > PHP教程 > php类库 > 列表

php编写的一个E-mail验证类

发布:smiling 来源: PHP粉丝网  添加日期:2021-05-18 10:22:33 浏览: 评论:0 

这篇文章主要介绍了php编写的一个E-mail验证类的用法,非常的简单实用,需要的小伙伴参考下,可以直接拿走使用。

这个类可以用来检查电子邮件是否有效使用SMTP协议。

它可以连接到由地址的域名来验证的MX记录中定义的SMTP服务器。

并且模拟消息的传递,以查看是否在给定的收件人地址被接受为有效。

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. <html> 
  3.   <head> 
  4.     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
  5.     <title>Sample</title> 
  6.   </head> 
  7.   <body> 
  8.     <?php 
  9.     //www.codepearl.com 
  10.     include_once 'class.verifyEmail.php'
  11.    
  12.     $email = 'verify@codepearl.com'
  13.    
  14.     $vmail = new verifyEmail(); 
  15.    
  16.     if ($vmail->check($email)) { 
  17.       echo 'email &lt;' . $email . '&gt; exist!'
  18.     } elseif ($vmail->isValid($email)) { 
  19.       echo 'email &lt;' . $email . '&gt; valid, but not exist!'
  20.     } else { 
  21.       echo 'email &lt;' . $email . '&gt; not valid and not exist!'
  22.     } 
  23.     ?> 
  24.   </body> 
  25. </html> 

以上所述就是本文给大家分享的全部内容了,希望对大家熟练掌握PHP能够有所帮助。

Tags: E-mail验证类

分享到: