Home  >  Article  >  Backend Development  >  php function to verify email address

php function to verify email address

WBOY
WBOYOriginal
2016-07-25 09:03:15897browse
  1. function is_valid_email($email, $test_mx = false)
  2. {
  3. if(eregi("^([_a-z0-9-]+)(.[_a-z0-9-]+)*@([a-z0-9-]+)(.[a-z0-9-]+)*(.[a-z]{2,4})$", $email))
  4. if($test_mx)
  5. {
  6. list($username, $domain) = split("@", $email);
  7. return getmxrr($domain, $mxrecords);
  8. }
  9. else
  10. return true;
  11. else
  12. return false;
  13. }
  14. ?>
复制代码


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn