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

时间:2022-08-24 13:42:51

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

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

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

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!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>
    <?php
    //www.codepearl.com
    include_once 'class.verifyEmail.php';
 
    $email = 'verify@codepearl.com';
 
    $vmail = new verifyEmail();
 
    if ($vmail->check($email)) {
      echo 'email &lt;' . $email . '&gt; exist!';
    } elseif ($vmail->isValid($email)) {
      echo 'email &lt;' . $email . '&gt; valid, but not exist!';
    } else {
      echo 'email &lt;' . $email . '&gt; not valid and not exist!';
    }
    ?>
  </body>
</html>

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

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