jueves, agosto 25, 2005

(PHP) Funciones para validar Mail

Validar un mail que contenga la "@" y además checa si el dominio existe:

Para LINUX:


function validar_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;
}
}
?>

Para WINDOWS:



function checkdnsrr_winNT( $host, $type = '' ){
if( !empty( $host ) )
{
if( $type == '' ) $type = "MX";
@exec( "nslookup -type=$type $host", $output );
while( list( $k, $line ) = each( $output ) )
{
if( eregi( "^$host", $line ) )
{
return true;
}
}
return false;
}
}
?>

No hay comentarios.: