Since erigi()
is deprecated in PHP 5 and I am in a need to validate an e-mail id, which function should be used? I need the format for e-mail validation such as:
<?php
function checkEmail($email)
{
if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email))
{
return FALSE;
}
list($Username, $Domain) = split("@",$email);
if(getmxrr($Domain, $MXHost))
{
return TRUE;
}
else
{
if(fsockopen($Domain, 25, $errno, $errstr, 30))
{
return TRUE;
}
else
{
return FALSE;
}
}
}
?>
Use the filter_var
PHP function instead:
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
}
Or, even better yet, use a RFC-compliant email address validator. As no amount of regex will encompass all the valid emails that are possible.