ok.. here it is. pg 352-355....
section 13.5
problem: checking to see if an e-mail is valid
solution: there's no way to be completely sure without trying the address, but to weed out typos, there's several patterns. if the IMAP extension is enabled, you can use imap_rfc822_parse_adrlist():
Code: Select all
$parsed=imap_rfc822_parse_adrlist($email_address, $default_host);
if('INVALID_ADDRESS'==$parsed['mailbox']{
#badaddress
}
the pattern they suggest:
/^[^@\s+@([-a-z0-9]+\.)+[a-z]{2,}$/i
they other pattern they give is
/^[^@\s]+@([-a-z0-9]+\.)+([a-z]{2}|com|net|edu|org|gov|mil|int|biz|pro|info|arpa|aero|coop|name|museum)$/ix
both of their patters only really look at what's after the at. the pattern i made, which seems to do what you want, also checks the begining has no spaces (both of these don't from the write up)
if(!(preg_match('/[\w\.\-]+@[\w\.\-]+\.\w\w\w?/', $email))){$err=TRUE; $errs[]='Your E-Mail address does not appear to be valid'; $step=2;}
that uses perl's regular expression instead of the posix one.
it looks for any number of the characters in \w (A-Z,a-z,0-9,_) . and - repreated any number of times, followed by an @ followed by the first thing again until .\w\w with an optional 3rd, so that it gets all the 2 letter names and 3 letter names.