title: How to validate the username of email address?
body: <p>I have my code below, I'm able to validate the domain but unable to validate the username even the domain name is valid.</p>
  
  <p>For example:</p>
  
  <pre><code>mon@hotmail.com  --- valid domain valid username  ---- pass
  aksjdsk@hotmail.com ----- valid domain invalid username  ---- failed
  </code></pre>
  
  <p>Appreciated if anyone can help. </p>
  
  <pre><code>function domain_exists($email, $record = 'MX'){
  list($user, $domain) = preg_split('/@/', $email);
  return checkdnsrr($domain, $record);}
  
  if(!domain_exists($email)){
  echo "&lt;script type='text/javascript'&gt;window.alert('No have such email,invalid Domain. please enter valid email address!')&lt;/script&gt;";
  echo "&lt;script type='text/javascript'&gt;window.location='register.html'&lt;/script&gt;";
  exit;}
  
  function user_exists($email, $record = 'MX'){
  list($user, $domain) = preg_split('/@/', $email);
  return checkdnsrr($user, $record);}
  
  if(!user_exists($email)){
  echo "&lt;script type='text/javascript'&gt;window.alert('No have such user, please enter valid email address!')&lt;/script&gt;";
  echo "&lt;script type='text/javascript'&gt;window.location='register.html'&lt;/script&gt;";
  exit;}
  </code></pre>