If I have an email address: me@example.com, how do I check with PHP that example.com is a valid domain. I want to do this beyond just making sure the syntax is correct. Isn't there a simple function that does some kind of lookup?

    This does what you want

    	function verifyemail_validatehost($email, $return_mxhost=0) {
    		if (!verifyemail_validateemail($email)) {
    			return false;
    			exit;
    		}
    
    	list($local,$domain) = explode("@",$email,2);
    
    	$mxhosts = array();
    	if(!checkdnsrr($domain, "MX") || !getmxrr($domain, $mxhosts)) {
    		return false;
    		exit;
    	}
    
    	if ($return_mxhost) {
    		return $mxhosts;
    		exit;
    	}
    
    	return true;
    }
    
      Write a Reply...