Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

Email Domain Validation

This has been bugging me for a while now, we often get tickets with emails that don't have correct domains, eg hptmail.com or gmaii.com. A while back I looked at customizing the way email addresses are validated on new ticket creations, solved it today. Just replace the function is_email($email) { from class.validation.php in the includes directory with the following code.

Basically for anyone that doesn't know PHP, this function now uses a basic RegEx or regular expression match to look for a valid email address eg me@mydomain.com but then also now does an MX Record lookup to ensure that the domain exists.

function is_email($email) {
$exp = "^[a-z\'0-9]+([._-][a-z\'0-9]+)*@([a-z0-9]+([._-][a-z0-9]+))+$";
if(eregi($exp,$email)){
 if(checkdnsrr(array_pop(explode("@",$email)),"MX")){
   return true;
  }else{
   return false;
  }
  }else{
   return false;
 }
}

Your Welcome :-)

Comments

Sign In or Register to comment.