Reputation: 379
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?
Upvotes: 2
Views: 2882
Reputation: 2087
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.
Upvotes: 3