Return to Snippet

Revision: 62180
at February 6, 2013 23:05 by NaetoH


Initial Code
function checkEmail($email) {
        $validate = filter_var($email, FILTER_VALIDATE_EMAIL);
        if ($validate) {
            $dns = substr(strchr($email, '@'), 1);
            if (checkdnsrr($dns, "MX")) {
                return array('errors' => false, 'message' => 'good email');
            } else {
                return array('errors' => true, 'message' => "Domain name for email doesn't exist");
            }
        } else {
            return array('errors' => true, 'message' => "Invalid email");
        }
    }

Initial URL


Initial Description
Check the email validity with filter_var and checkdns

Initial Title
Check email validity with domain name

Initial Tags
email

Initial Language
PHP