Announcing a couple of PHP scripts that I think have been a long time in
coming ... 

validateEmail - 2.0
A much needed updating of the validateEmail function created in '98 by Jon
S. Stevens, and updated by Shane Gibson, berber, and Frank Vogel over time.
Several new features have been added, including an improved "wait" routine
for sluggish hosts, and RFC 2821-compliant SMTP command formatting to
eliminate "hang" problems caused by attempts to validate on certain hosts.

I realize there is quite a bit of controversy over the validation methods
used by this script -- therefore, some people may not favor it. However, I
feel it's an effective first line of defense against the "[EMAIL PROTECTED]"
sort of garbage, etc. Those who use validateEmail now will find this to be a
useful upgrade.

validateEmailFormat - 1.0
The PHP online docs say the following in the "add a note" section:

"(And if you're posting an example of validating email addresses, please
don't bother. Your example is almost certainly wrong for some small subset
of cases. See this information from O'Reilly Mastering Regular Expressions
book for the gory details.)"

Good advice, I think. So good, in fact, that I figured it was time someone
just went ahead and translated that regex into PHP. This code is distributed
in accordance with O'Reilly's policy on re-use of code examples from their
books. (

# # #

I fully recognize that there is no foolproof way to validate an e-mail
address (either its functionality or formatting) without actually sending a
message and requiring the user to respond. In the cases where that tactic is
not considered acceptable, I believe the combination of these two functions
is the next best thing.

validateEmail and validateEmailFormat are freely available at:

Comments, suggestions and questions encouraged. Enjoy!


Clay Loveless
KillerSoft -

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to