Home  >  Article  >  Backend Development  >  php编写的一个E-mail验证类_php实例

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

WBOY
WBOYOriginal
2016-06-07 17:13:43794browse

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

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

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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Sample</title>
  </head>
  <body>
    <&#63;php
    //www.codepearl.com
    include_once 'class.verifyEmail.php';
 
    $email = 'verify@codepearl.com';
 
    $vmail = new verifyEmail();
 
    if ($vmail->check($email)) {
      echo 'email <' . $email . '> exist!';
    } elseif ($vmail->isValid($email)) {
      echo 'email <' . $email . '> valid, but not exist!';
    } else {
      echo 'email <' . $email . '> not valid and not exist!';
    }
    &#63;>
  </body>
</html>

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

请您花一点时间将文章分享给您的朋友或者留下评论。我们将会由衷感谢您的支持!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn