1

I'm attempting to check if an exists but false is always returned even though my email address exists.

function EmailValidation($email)
 { 
    $email = htmlspecialchars(stripslashes(strip_tags($email))); //parse unnecessary characters to prevent exploits

    if (filter_var($email, FILTER_VALIDATE_EMAIL)) 
    { //checks to make sure the email address is in a valid format
    $domain = explode( "@", $email ); //get the domain name
        if ( @fsockopen ($email,80,$errno,$errstr,3)) 
        {
            //if the connection can be established, the email address is probably valid
            return "yes";
        } else 
        {
            return "no"; //if a connection cannot be established return false
        }
    //return "not valid"; //if email address is an invalid format return false
  }
}

 $ve = EmailValidation("[email protected]");

print_r($ve);

I have 500k emails, i've been given the task to find out, which emails exist and which don't. I don't want to send an email but check if the email is exist. How do i solve?

7
  • I have 500k emails, i've been given the task to find out, which emails exist and which don't.
    – mdnba50
    Commented Nov 22, 2017 at 11:34
  • 1
    @mdnba50 There's no way you can figure out if they exist or not unless you try to send a mail to all of them and then you can figure out which ones bounce (however, not all email servers will bounce the email - some might accept it and throw it out, so you won't know that they don't exist).
    – h2ooooooo
    Commented Nov 22, 2017 at 11:36
  • Check this stackoverflow.com/questions/19261987/… Commented Nov 22, 2017 at 11:36
  • A webserver running on the same domain is a poor indicator. I have several domains set for receiving emails - none of them host a website. Commented Nov 22, 2017 at 11:37
  • email-validator.net/email-address-online-verification-api.html it is an api provider which checks 100 email free. Commented Nov 22, 2017 at 11:49

1 Answer 1

2

It is impossible to check if an email address exists. Checking the host availability is also negligible because the biggest part of users use a good and reliable mail provider.

The only thing you can do, beside email name string validations, is to send an email to every entry and see if you will receive any error email back. Most provider give you a undeliverable message when the email doesn't exist anymore. But this can happen after 1 minute, after 1 hours, after 1 day or anytime later.

Conclusion: It's impossible to check if email addresses really exist.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.