function validMail.php
Muchas veces tengo que comprobar si un correo que escriben en algun formulario es un correo válido, algunas otras veces esto se complica pues algunas expresiones regulares pueden ser fácilmente engañadas con un a@a.a, con esta función podemos verificar mas a fondo si este es un correo real.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | /* validMail():Boolean @email -> string: email a comparar @validate -> Boolean: conectarse al servidor a buscar dicho usuario */ function validMail($email,$validate = false) { if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) return false; if ($validate){ list ( $Username, $Domain ) = split ("@",$email); if (getmxrr($Domain, $MXHost)) $ConnectAddress = $MXHost[0]; else $ConnectAddress = $Domain; $Connect = fsockopen( $ConnectAddress, 25 ); if ($Connect) { if (ereg("^220", $Out = fgets($Connect, 1024))) { fputs ($Connect, "HELO $HTTP_HOST\r\n"); $Out = fgets ( $Connect, 1024 ); fputs ($Connect, "MAIL FROM: <{$email}>\r\n"); $From = fgets ( $Connect, 1024 ); fputs ($Connect, "RCPT TO: <{$email}>\r\n"); $To = fgets ($Connect, 1024); fputs ($Connect, "QUIT\r\n"); fclose($Connect); if (!ereg ("^250", $From) || !ereg ( "^250", $To )) { return false; } }else{ return false; } }else{ return false; } } return true; } ?> |
October 25th, 2007 at 1:43 am
prueba
June 12th, 2011 at 9:12 pm
Hello my loved one! I want to say that this post is awesome, nice written and come with approximately all important infos. I’d like to see more posts like this .
July 7th, 2011 at 7:25 pm
I am extremely impressed together with your writing abilities and also with the layout on your blog. Is this a paid subject or did you customize it yourself? Either way keep up the excellent high quality writing, it is rare to peer a nice weblog like this one nowadays..