Home > php教程 > PHP源码 > body text

一个低调有内涵的E-mail验证类!

PHP中文网
Release: 2016-05-20 12:56:33
Original
1668 people have browsed it

这个类可以用来检查电子邮件是否有效使用SMTP协议。
它可以连接到由地址的域名来验证的MX记录中定义的SMTP服务器。
并且模拟消息的传递,以查看是否在给定的收件人地址被接受为有效。

1.代码

<!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 &#39;class.verifyEmail.php&#39;;
 
        $email = &#39;verify@codepearl.com&#39;;
 
        $vmail = new verifyEmail();
 
        if ($vmail->check($email)) {
            echo &#39;email &lt;&#39; . $email . &#39;&gt; exist!&#39;;
        } elseif ($vmail->isValid($email)) {
            echo &#39;email &lt;&#39; . $email . &#39;&gt; valid, but not exist!&#39;;
        } else {
            echo &#39;email &lt;&#39; . $email . &#39;&gt; not valid and not exist!&#39;;
        }
        ?>
    </body>
</html>
Copy after login
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!