Ping for Email Authentication

Is there anyway to ping an email address or something like that to check with him a real work address. I'm not talking about regex or php validate filters, etc., but does address validation actually exist?

+5
source share
3 answers

It is possible, but not reliable, to connect to the recipient's mail server and offer mail, suggesting the mail server to reject or accept mail. Not all mail servers will verify the addresses are correct, so do not rely on them. A similar question is here .

+3
source

(90% !):

function validate_email($email)
{
    if(!preg_match ("/^[\w\.-]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]+$/", $email))
        return false;
    list($prefix, $domain) = explode("@",$email);
    if(function_exists("getmxrr") && getmxrr($domain, $mxhosts))
        return true;
    elseif (@fsockopen($domain, 25, $errno, $errstr, 5))
        return true;
    else
        return false;
}
+2

, MX : getmxrr() http://php.net/manual/en/function.getmxrr.php

: - a simple - a simple , tld

// pattern was taken from PHP own source
$pattern =  "/^((\\\"[^\\\"\\f\\n\\r\\t\\b]+\\\")|([A-Za-z0-9_][A-Za-z0-9_\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]*(\\.[A-Za-z0-9_\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]*)*))@((\\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9])(([A-Za-z0-9\\-])*([A-Za-z0-9]))?(\\.(?=[A-Za-z0-9\\-]))?)+[A-Za-z]+))$/D";
if (preg_match($pattern, $email)) {
    /**
     * allow ip address as domain OR it should be a valid TLD
     */
    $long = ip2long(substr($email, strrpos($email, '@')+1));
    return (($long !==FALSE && $long>-1)
        || isValidTld(substr($email, strrpos($email, '.')+1)));
}

- , , ... ( mx-check) ...

+1

All Articles