Posted By

paulgrenwood on 09/23/09


email php forms validate

Versions (?)

Who likes this?

3 people have marked this snippet as a favorite


Validate Email Address

 / Published in: PHP

E-mail validation is perhaps the most used validation in web forms, this code will validate email address and also optionally check the MX records of the domain provided in email address to make email validation more robust.

  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. }

Report this snippet  


RSS Icon Subscribe to comments
Posted By: Jacky888 on October 1, 2018

irbis tz752 gofirmware

Posted By: Jacky888 on October 14, 2018

the 8 best ihome ip46 portable speaker system topportablespeaker

You need to login to post a comment.