How to check valid email address using PHP?

Dear Friends,

I’ve written a PHP function, It will check and return true if given email address is a valid email address and it will return false if give email address is not a valid email address. The important thing is that in this function that it will also check that given domain name is working and valid domain name or not. It gets MX records of given domain name.

function is_email($email) {
	// checks proper syntax
	if( !preg_match( "/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $email))
		return false;
	// gets domain name
	// checks for if MX records in the DNS
	$mxhosts = array();

	return (getmxrr($domain, $mxhosts));

function win_getmxrr($hostname, &$mxhosts, &$mxweight=false) {
	if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') return;
	if (!is_array ($mxhosts) ) $mxhosts = array();
	if (empty($hostname)) return;
	$exec='nslookup -type=MX '.escapeshellarg($hostname);
	@exec($exec, $output);
	if (empty($output)) return;
	foreach ($output as $line) {
		if (preg_match("/^$hostname\tMX preference = ([0-9]+), mail exchanger = (.+)$/i", $line, $parts)) {
		  $mxweight[$i] = trim($parts[1]);
		  $mxhosts[$i] = trim($parts[2]);
		if (preg_match('/responsible mail addr = (.+)$/i', $line, $parts)) {
		  $mxweight[$i] = $i;
		  $mxhosts[$i] = trim($parts[1]);
	return ($i!=-1);

$email = "";
if (is_email($email))
	echo "Valid email address.";
	echo "Invalid email address.";