La toma de posesión Validar correo electrónico en Javascript y PHP , aquí hay una buena clase de JavaScript capaz de verificar y comprobar el correo electrónico. Su uso es muy sencillo, a pesar de que es un control del lado del cliente, y fácil pasar por alto, usted puede desactivar Javascript (proponer petición en contra de esta posibilidad
Ahora todos los navegadores permiten JavaScript para evadir, y luego todos los controles asociados con - en el corto plazo no es algo en Internet, ver Ajax
).
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | / * ** @ Nombre: ckmail.js ** @ Descripción: Revisa tu correo electrónico sintaxis ** @ Autor: deshacer = = ** @ Autor-Web: http://www.undolog.com ** @ Autor: correo electrónico: @ g.fazioli undolog.com - g (punto) Fazioli (a) undolog (dot) com ** @ Fecha: 21/09/2006 21:24 ** @ Ver: 1.0 * / { oCKMail = {var , __release: "1.0", , __filter: / ^ (.. [\ w-]+(?: \ [\ w-]+)*)@((?:[ \ w-] + \) * \ w [\ w-] {0, 66}) \ ([az] {2,6} (:.?. \ [az] {2 })?)$/ i, , __username: "", , __domain: "", , __ext: "", / / HACER ( e ) { GetUserName: function (e) { this .__init ( e ) ) return ( this .__username ) ; if (this. __init (e)) return (__username this.); false ) ; return (false); }, / / HACER ( e ) { GetDomain: function (e) { this .__init ( e ) ) return ( this .__domain ) ; if (this. __init (e)) return (this. __domain); false ) ; return (false); }, / / HACER ( e ) { GetExtension: function (e) { this .__init ( e ) ) return ( this .__ext ) ; if (this. __init (e)) return (this. __ext); false ) ; return (false); }, / / HACER ( e ) { __init: function (e) { ! this .__filter. test ( e ) ) return ( false ) ; si el retorno (false) (esta prueba __filter (e)!..); e. split ( "@" ) ; e. var t = split ("@"); t [ 0 ] ; este __username t = [0].; t [ 1 ] ; este __domain = t [1].; .__domain. split ( "." ) ; t = esto. __domain. dividida ("."); t [ 1 ] ; este __ext = t [1].; true ) ; return (true); }, / / HACER / / Sinopsis / / Check (y extlist, domainlist); / / Ejecuta una serie de controles estándar de un e-mail. / / Extlist - Puede pasar un segundo parámetro opcional que corresponde a una serie de extensiones que / / Son permitidos o excluidos (incluir / excluir de extensión) de acuerdo con el primer valor de la matriz, todas las / / Otro error será considerado. / / Por ejemplo. [Es cierto, "en", "com"] pass (incluye la lista) / / Por ejemplo. [False, "en", "com"] no pase (lista de exclusión) / / Si -1 no se tiene en cuenta / / Domainlist - Se puede pasar un tercer parámetro que corresponde a una serie de dominios que / / Son permitidos o excluidos (incluir / excluir de dominio) de acuerdo con el primer valor de la matriz, todas las / / Otro error será considerado. / / Por ejemplo. [Es cierto que "alice.it", "mac.com"] pass (incluye la lista) / / Por ejemplo. [False, "alice.it", "mac.com"] no pase (lista de exclusión) / / Si -1 no se tiene en cuenta / / ( e ) { ver: function (e) { this .__init ( e ) ) { if (this. __init (e)) { / / Comprobar comprobar serie domainExt arguments. length > 1 ) { if (arguments. longitud> 1) { typeof ( arguments [ 1 ] ) == "object" ) { if (typeof (arguments [1]) == "object") { arguments [ 1 ] [ 0 ] ) { // include list if (arguments [1] [0]) {/ / include lista var i = 0 ; i < arguments [ 1 ] . length ; i ++ ) { for (var i = 0; i <argumentos [1] de longitud;. i + +) { this .__ext == arguments [ 1 ] [ i ] . toLowerCase ( ) ) return ( true ) ; if (this. __ext == argumentos [1] [i] toLowerCase ().) return (true); } { // exclude list Else {} / / lista de exclusión var i = 0 ; i < arguments [ 1 ] . length ; i ++ ) { for (var i = 0; i <argumentos [1] de longitud;. i + +) { this .__ext == arguments [ 1 ] [ i ] . toLowerCase ( ) ) return ( false ) ; if (this. __ext == argumentos [1] [i] toLowerCase ().) return (false); } true ) ; return (true); } false ) ; return (false); } } / / Comprobar comprobar serie domainName arguments. length > 2 ) { if (arguments. longitud> 2) { typeof ( arguments [ 2 ] ) == "object" ) { if (typeof (argumentos [2]) == "object") { arguments [ 2 ] [ 0 ] ) { // include list if (argumentos [2] [0]) {/ / include lista var i = 1 ; i < arguments [ 2 ] . length ; i ++ ) { for (var i = 1, i <argumentos [2] de longitud;. i + +) { this .__domain == arguments [ 2 ] [ i ] . toLowerCase ( ) ) return ( true ) ; if (this. __domain == argumentos [2] [i] toLowerCase ().) return (true); } { // exclude list Else {} / / lista de exclusión var i = 1 ; i < arguments [ 2 ] . length ; i ++ ) { for (var i = 1, i <argumentos [2] de longitud;. i + +) { this .__domain == arguments [ 2 ] [ i ] . toLowerCase ( ) ) return ( false ) ; if (this. __domain == argumentos [2] [i] toLowerCase ().) return (false); } true ) ; return (true); } false ) ; return (false); } } true ) ; // email correct return (true) / / e-mail correcta } false ) ; // error return (false) / error / } }; |
El objeto oCKMail ofrece varios métodos para llevar a cabo una serie paralela de los controles de la dirección, tales como la extensión, dominio, etc ...
Para que sea realmente seguro de si tiene PHP, usted puede agregar un control adicional y efectiva antes de ejecutar el comando mail() . Aquí está la clase PHP útil para este propósito:
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | / * ** @ Nombre: cckmail.php ** @ Descripción: Revisa tu correo electrónico sintaxis ** @ Autor: deshacer = = ** @ Autor-Web: http://www.undolog.com ** @ Autor: correo electrónico: @ g.fazioli undolog.com - g (punto) Fazioli (a) undolog (dot) com ** @ Fecha: 21/09/2006 23:58 ** @ Ver: 1.0 ** ** Ejemplos ** ** / / Buscar una dirección SIN el dominio de correo electrónico "e-lementi.com" y "mac.com" ** ** $ OCKMail CCKMail = new (); ** $ OCKMail-> ver ($ email, NULL, array (false, "e-lementi.com", "mac.com")); ** ** / / Comprobar la dirección incluido el dominio de correo electrónico "e-lementi.com" y "mac.com" ** ** $ OCKMail CCKMail = new (); ** $ OCKMail-> ver ($ email, NULL, array (true, "e-lementi.com", "mac.com")); ** ** / / Buscar una dirección EXCLUYENDO los mensajes de correo electrónico con una "red", "en", "org" ** ** $ OCKMail CCKMail = new (); ** $ OCKMail-> ver ($ email, array (false, "net", "en", "org")); ** ** HISTORIA / Cambio de registro ** * / ! function_exists ( 'checkdnsrr' ) ) { if ( function_exists ('checkdnsrr')) { ( $host , $type = '' ) { función checkdnsrr ($ host, $ type ='') { ! empty ( $host ) ) { if ( vacío ($ host)) { $type == '' ) $type = "MX" ; if ($ tipo =='') tipo $ = "MX"; ( "nslookup -type= $type $host " , $output ) ; @ ejecutivo ("tipo nslookup-= $ tipo $ host", $ salida); list ( $k , $line ) = each ( $output ) ) { while ( lista ($ k, $ line) = Cada uno ($ salida)) { eregi ( "^ $host " , $line ) ) { if ( eregi ("^ $ host", $ linea)) { ; return true; } } ; return false; } } } / / {CCKMail clase = "1.1" ; var $ __release = "1.1"; = false ; var $ estado = false; ; var $ nombre; ; var $ dominio; ; var $ ext; / / CCKMail función () {} / / $e ) { función _test ($ s) { status = false ; $ This -> Estado = false; '/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/' ; $ P ='/^.+ \ @ (\ [?) [A-Za-Z0-9 \ - \] + \ ([a-zA-Z] {2,4} |.. [0-9] {1,3}) (\ ]?)$/'; preg_match ( $p , $e ) ) ) { if (( preg_match ($ p, $ e))) { explode ( "@" , $e ) ; $ T = explotar ("@", $ s); username = strtolower ( $t [ 0 ] ) ; $ This -> nombre de usuario = strtolower ($ t [0]); domain = strtolower ( $t [ 1 ] ) ; $ This -> dominio = strtolower ($ t [1]); explode ( "." , $this -> domain ) ; $ T = explotar ('.', $ this - dominio>); ext = strtolower ( $t [ 1 ] ) ; $ This -> ext = strtolower ($ t [1]); / / checkdnsrr ( $this -> domain . '.' , 'MX' ) ) $this -> status = true ; if ( checkdnsrr ($ this -> dominio ..'', 'MX')) $ this -> Estado = true; checkdnsrr ( $this -> domain . '.' , 'A' ) ) $this -> status = true ; if ( checkdnsrr ($ this -> dominio ..'', 'A')) $ this -> estado = true; checkdnsrr ( $this -> domain . '.' , 'CNAME' ) ) $this -> status = true ; if ( checkdnsrr ($ this -> dominio ..'', 'CNAME')) $ this -> Estado = true; } } / / $m , $e = NULL , $d = NULL ) { función de verificación ($ m, $ e = NULL, $ d = NULL) { _test ( $m ) ; $ This -> _test ($ m); $this -> status ) { if ($ this -> Estado) { / / Comprobar comprobar serie domainExt ! is_null ( $e ) ) { if ( is_null ($ e)) { $e [ 0 ] ) { // include list if ($ e [0]) {/ / include lista $i = 1 ; $i < sizeof ( $e ) ; $i ++ ) { for ($ i = 1; $ i < sizeof ($ s); $ i + +) { $this -> ext == strtolower ( $e [ $i ] ) ) return ( true ) ; if ($ this -> ext == strtolower ($ e [$ i])) return (true); } { // exclude list Else {} / / lista de exclusión $i = 1 ; $i < sizeof ( $e ) ; $i ++ ) { for ($ i = 1; $ i < sizeof ($ s); $ i + +) { $this -> ext == strtolower ( $e [ $i ] ) ) return ( false ) ; if ($ this -> ext == strtolower ($ e [$ i])) return (false); } true ) ; return (true); } false ) ; return (false); } / / Comprobar comprobar serie domainName ! is_null ( $d ) ) { if ( is_null ($ d)) { $d [ 0 ] ) { // include list if ($ d [0]) {/ / include lista $i = 1 ; $i < sizeof ( $d ) ; $i ++ ) { for ($ i = 1; $ i < sizeof ($ d); $ i + +) { $this -> domain == strtolower ( $d [ $i ] ) ) return ( true ) ; if ($ this -> dominio == strtolower ($ d [$ i])) return (true); } { // exclude list Else {} / / lista de exclusión $i = 1 ; $i < sizeof ( $d ) ; $i ++ ) { for ($ i = 1; $ i < sizeof ($ d); $ i + +) { $this -> domain == strtolower ( $d [ $i ] ) ) return ( false ) ; if ($ this -> dominio == strtolower ($ d [$ i])) return (false); } true ) ; return (true); } false ) ; return (false); } true ) ; return (true); } false ) ; return (false); } } > |
¿Qué ineteressante es la capacidad de esta clase para conectar a los servidores MX (ver checkdnsrr() ) para verificar la presencia del dominio. Así, además de realizar una comprobación de sintaxis del correo electrónico se ejecuta un dominio de ping real antes. Podemos decir con seguridad que este método es del 80% ...










[...] También puede introducir un control adicional en el servidor / php. Véase en este sentido las clases Javascript y PHP para validar e-mail TEXTO un'indirizzo PLAIN [...]