Reputation: 918
Is there any way to check (through PHP) that whether any given email address is active (means is it currently being used & opened by anyone) or not (means it is blocked or no one uses/opens it, it's inactive)?
Regards & Thanks in advance.
Upvotes: 3
Views: 1717
Reputation: 449823
Is there any way to check (through PHP) that whether any given email address is active (means is it currently being used & opened by anyone) or not (means it is blocked or no one uses/opens it, it's inactive)?
No.
The only way to be sure is to send an E-Mail to the address, not get a bounce message, and get some kind of reply back (like an answer, or the user clicking a unique link in the E-Mail, or an image with a unique URL being opened [this is frowned upon though, and blocked by many E-Mail clients], or a read receipt). None of these methods is foolproof, though, so you can never tell for 100% sure.
Upvotes: 3
Reputation: 73
I think you are asking if the email user enters is valid or not!! if this is the case then you should use nslookup for unix-based operating system with help of exec.. here is a small function for that: (i am checking if the domain is correct or not)
function myCheckDNSRR($email)
{
list($userName, $hostName) = split("@", $email);
$recType = '';
if(!empty($hostName)) {
if( $recType == '' ) $recType = "MX";
exec("nslookup -type=$recType $hostName", $result);
// check each line to find the one that starts with the host
// name. If it exists then the function succeeded.
foreach ($result as $line) {
if(eregi("^$hostName",$line)) {
return true;
}
}
// otherwise there was no mail handler for the domain
return false;
}
return false;
}
Upvotes: 2
Reputation: 26307
You can but have to use an API to an external service
There are a few email validation api's out there, data8 got one. http://www.data-8.co.uk/integr8/services/email_validation.aspx
Here is a sample
function IsValid($email, $level)
{
$params = array(
"username" => "your-username",
"password" => "your-password",
"email" => $email,
"level" => $level,
"options" => $options
);
$client = new SoapClient("http://webservices.data-8.co.uk/EmailValidation.asmx?WSDL");
$result = $client->IsValid($params);
if ($result->IsValidResult->Status->Success == 0)
{
echo "Error: " . $result->IsValidResult->Status->ErrorMessage;
}
else
{
// TODO: Process method results here.
// Results can be extracted from the following fields:
// $result->IsValidResult->Result
// Contains a status code indicating if the email address could be validated.
}
}
Upvotes: 0