help making a better email check
current: preg_match('/^[\w\.\-]+@[\w\.\-]+\.\w\w\w?$/', $email)
a friend typoed nrt for net. so i figure even with two feilds ineed a better check. i want to allow the two letter country codes and all the 3/4 letter domains (i don't see anyone using museum)
does anyone know a place that has an up to date list? will the others with prel reg exp skim this quickly and make sure i didn't screw up (i find that i have a tendency to make minor mistakes, if i did it should be caught by one of you i expect... don't have a way to test this until i can get a friend to try it, which might be after you look at it)
new: preg_match('/^[\w\.\-]+@[\w\.\-]+\.(\w\w|biz|com|org|gov|net|info)$/', $email)
POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.
m3rajk posted this at 07:16 — 18th January 2004.
They have: 461 posts
Joined: Jul 2003
http://forums.devnetwork.net/viewtopic.php?t=16863
ROB posted this at 05:10 — 19th January 2004.
They have: 447 posts
Joined: Oct 1999
i've been using this forever:
function validate_email(&$email) {
if( preg_match("/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/",$email) ||
!preg_match("/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/",$email)
) return 0;
return 1;
}
Mark Hensler posted this at 07:20 — 20th January 2004.
He has: 4,048 posts
Joined: Aug 2000
What about IPs? I'm pretty sure you can email a user@IP.
Read section 4.1.3 of RFC 2821.
m3rajk posted this at 22:27 — 20th January 2004.
They have: 461 posts
Joined: Jul 2003
thanx mark. i missed that. i got a list of top levels and added those to check against that. i knew about the two letters and to make that easier used \w\w, but apparently \w\w\d? is what i should have there.
POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.