How to check if an email address exists without sending an email?

前端 未结 14 1744
半阙折子戏
半阙折子戏 2020-11-22 00:28

I have come across this PHP code to check email address using SMTP without sending an email.

Has anyone tried anything similar or does it work for you? Can you tell

相关标签:
14条回答
  • 2020-11-22 01:30
    <?php
    
       $email = "someone@exa mple.com";
    
       if(!filter_var($email, FILTER_VALIDATE_EMAIL))
          echo "E-mail is not valid";
       else
          echo "E-mail is valid";
    
    ?>
    
    0 讨论(0)
  • 2020-11-22 01:31
    function EmailValidation($email)
    {
        $email = htmlspecialchars(stripslashes(strip_tags($email))); //parse unnecessary characters to prevent exploits
        if (eregi('[a-z||0-9]@[a-z||0-9].[a-z]', $email)) {
            //checks to make sure the email address is in a valid format
            $domain = explode( "@", $email ); //get the domain name
            if (@fsockopen ($domain[1],80,$errno,$errstr,3)) {
                //if the connection can be established, the email address is probably valid
                echo "Domain Name is valid ";
                return true;
            } else {
                echo "Con not a email domian";
                return false; //if a connection cannot be established return false
            }
            return false; //if email address is an invalid format return false
        }
    }
    
    0 讨论(0)
提交回复
热议问题