pimenz
05-01-2003, 10:08 AM
How can I validate an e-mail address using PHP.
My code:
function myCheckDNSRR($hostName, $recType = '')
{
if(!empty($hostName)) {
f( $recType == '' ) $recType = "MX";
exec("nslookup -type=$recType $hostName", $result);
foreach ($result as $line) {
if(eregi("^$hostName",$line)) {
return true;
}
}
return false;
}
if (myCheckDNSRR("mydomain.com","MX"))
echo "yup - valid email!";
else
echo "nope - invalid email!";
But this only checks if the domain mydomain.com exists. But say now my e-mail is someone@mydomain.com
How do I check if the box someone exists on the domain.
My code:
function myCheckDNSRR($hostName, $recType = '')
{
if(!empty($hostName)) {
f( $recType == '' ) $recType = "MX";
exec("nslookup -type=$recType $hostName", $result);
foreach ($result as $line) {
if(eregi("^$hostName",$line)) {
return true;
}
}
return false;
}
if (myCheckDNSRR("mydomain.com","MX"))
echo "yup - valid email!";
else
echo "nope - invalid email!";
But this only checks if the domain mydomain.com exists. But say now my e-mail is someone@mydomain.com
How do I check if the box someone exists on the domain.