Maybe I'm biased, but if you grab validateEmailFormat.php from
www.killersoft.com, you'd be able to do something as simple as this:

<?php
include("/path/to/validateEmailFormat.php");

$email = "[EMAIL PROTECTED]";
$isValid = validateEmailFormat($email);
if($isValid) {
    // do whatever you need to do
} else {
    echo "sorry, that address isn't formatted properly.";
}
?>

validateEmailFormat.php is a translation of the Perl regular expression
that's widely considered to be the defintive test of a valid RFC822 address.
Can't go wrong with that. : )


-Clay


> From: Justin French <[EMAIL PROTECTED]>
> Date: Sun, 02 Jun 2002 14:13:40 +1000
> To: php <[EMAIL PROTECTED]>
> Subject: [PHP] simple email validation ereg
> 
> Hi,
> 
> I know that there are more complex functions and classes out there for
> validating email address', but some of them do return "invalid" on
> *technically* valid, although uncommon email address', so all I want is a
> simple test for:
> 
> (anything)@(anything) followed by 1 or more (.anything)
> 
> ie
> foo@foo : invalid
> [EMAIL PROTECTED] : valid
> [EMAIL PROTECTED] : valid
> 
> i wish to allow ANYTHING really -- not just a-z,A-z,0-9,_,- technically
> spaces, brackets, and all sorts of crap are valid in the user portion of the
> email address :)
> 
> 
> this will return true for [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED]
> etc etc... i'm aware that the results will not necessarily BE valid email
> address', but at least they'll *look* like valid email address'.
> 
> it's for a simple guestbook/message board where some creative people have
> put in "lalaland" or "myplace" as an email address, rather than entering
> something that at least LOOKS like a valid address, or optionally leaving
> the field blank.
> 
> my aim will be to strip out anything that doesn't at least LOOK like like an
> email address.
> 
> 
> regards,
> 
> justin french
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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

Reply via email to