PHP5 Email verification

By | April 2, 2012

Amazing how so many people have such long and complex answers to a simple question.

Question: How do you validate a email address in PHP5?

Answer: function validemail($var) {

if (filter_var(filter_var($var, FILTER_SANITIZE_EMAIL), FILTER_VALIDATE_EMAIL)) {
list($username,$domain)=split('@',$var);
if(!checkdnsrr($domain,'MX')) {
return false;
}
return true;
}
return false;
}

Damn people…. it wasn’t that hard!!! Once I gave up on other peoples answers, I decided to get my head on straight and did that.

Next, will be a easy was to handle a sub domain MX record…

Comments

comments

Leave a Reply