Reply to Re: Email Validation built-in? RFC

Your name:

Reply:


Posted by Manuel Lemos on 10/23/05 07:24

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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация