1 function checkEmail($email) 2 { 3 // Create the syntactical validation regular expression 4 $regexp = "^([_a-z0-9-]+)(.[_a-z0-9-]+)*@([a-z0-9-]+)(.[a-z0-9-]+)*(.[a-z]{2,4})$"; 5 6 // Presume that the email is invalid 7 $valid = 0; 8 9 // Validate the syntax 字符串比对解析,与大小写无关。 10 if (eregi($regexp, $email)) 11 { 12 list($username,$domaintld) = split("@",$email); 13 // Validate the domain 14 if (getmxrr($domaintld,$mxrecords)) 15 $valid = 1; 16 } else { 17 $valid = 0; 18 } 19 20 return $valid; 21 22 }