Email validation with MX check


/ Published in: PHP
Save to your folder(s)

found this somewhere online...not the author, but works like a charm


Copy this code and paste it in your HTML
  1. function checkEmail($email) {
  2. if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $email)){
  3. list($username,$domain)=split('@',$email);
  4. if(!checkdnsrr($domain,'MX')) {
  5. return false;
  6. }
  7. else {
  8. return true;
  9. }
  10. }
  11. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.