Re: Email Validation built-in? RFC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,


on 10/22/2005 12:58 AM Richard Lynch said the following:
Checking MX records is not reliable at all.

I agree that it is less useful today, but it still help catches many domain name typos.


... would it not make sense for there to be a BUILT-IN PHP function of
a TRUE email syntactic validation?

I don't see that being much better than passing a good regular expression to preg_match.


Currently, email syntax validation is being done in very limited
fashion, if not outright "wrong" by rejecting what actually ARE valid
email addresses in about 10,000,000 PHP scripts by users who don't
have any realistic options to truly "do it right" because who can
really live with that 3-page Regex in their PHP code?

For many years I use this regular expression in popular email validation and forms generation and validation classes.

http://www.phpclasses.org/formsgeneration

http://www.phpclasses.org/emailvalidation

Rather than accepting only valid characters, it rejects all invalid characters as specified in the RFC.

^([-!#$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,6}$

I think it could be enhanced to reject all invalid characters as specified in the RFC instead of accepting only the valid ASCII characters. It would be just a matter of changing a variable in both the classes above.

Other than using that expression in PHP, the forms class can do the same in Javascript to reduce server round trip to check the email format.

The email validation class can perform subsequent validation of DNS records and simulate delivery to see if the remote SMTP server would accept. It returns 3 kinds of results: Yes, no, maybe (not possible to determine for sure). It is even capable to distinguish a real rejection from a whitelist temporary rejection.

--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux