Posted By

brownrl on 06/26/09


Tagged

email php check validation hardcore


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

jseltzer
vali29
irishsk


PHP isValidEmail


 / Published in: PHP
 

URL: http://www.goingson.be

This is a slightly hard core email check. I work for clients that want real email addresses. They pay quite a bit of money so yes, I am going to give what they want...

  1. <?php
  2. // FUNCTION: isValidEmail( $email )
  3. //
  4. // return wether an email is valid.
  5. //
  6. // This is a hard core check cause we check the domain and we even check
  7. // that the email is not one of the disposable email places.
  8. //
  9. // undisposable.net is a great service!
  10. // tells wether or not the email you are getting
  11. // is a mailinator or other disposable address
  12. //
  13. // Sorry but when a client pays 40,000 Euros for a web campaign
  14. // they want real email addresses.
  15. //
  16. function isValidEmail( $email )
  17. {
  18. // first thing to do is
  19. // lets strip out the domain cause we are going to check the domain
  20. $domainname= explode("@",$email);
  21. $checkdomain= $domainname[1];
  22.  
  23. // check if the filter works, then check that the domain is real
  24. if( filter_var( $email , FILTER_VALIDATE_EMAIL) &&
  25. checkdnsrr( $checkdomain ) )
  26. {
  27. // ok it seems that we have real email address
  28. // now lets see if the email is in the disposable
  29. // email address lists.
  30.  
  31. $url = "http://www.undisposable.net/services/php/";
  32. $url .= "isDisposableEmail/?email=".addslashes($email);
  33. $res = @file_get_contents($url);
  34. $uns = @unserialize($res);
  35. if($uns['stat']=='ok')
  36. {
  37. return ( $uns['email']['isdisposable'] != "yes" );
  38. }
  39. else
  40. {
  41. return false;
  42. }
  43. }
  44. else
  45. {
  46. return false;
  47. }
  48. }
  49. ?>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: mz-opensource on June 28, 2009

what is that ?

Posted By: brownrl on June 30, 2009

what is what?

You need to login to post a comment.