Follow me on Twitter Facebook Flickr Subscribe Feeds
 

[PHP] Validare esistenza indirizzo email

This entry was posted on October 4th, 2008 and is filed under php.

Lo script seguente verifica se un indirizzo email è sintatticamente corretto e se il dominio inserito esiste realmente.


<?php
function validate_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")){
      print("$email is ok.");
    } else print("$email is ok. But domain is not.");
  } else print("$email is not ok.");
}

validate_email("blablallalb.ddddd");
validate_email("sandrostracuzzi@gmail.com");
validate_email("blablallalb@fbllbalblalblablblbla.com");
?>

Via | Sastgroup

Pixmac
Like this post? Share It! :)
Navigation:
Related Posts:
Comments

Comments are closed.