Page 1 of 2
E-mail Checking
Posted: Tue Jul 11, 2006 3:13 pm
by tecktalkcm0391
Does anybody have anywhere/code that checks if an email is an actually email address so users can't type something like
asdflkja0ifdjalkfjaigj@jlkajdflafdjlak.com and then my website execpts it.
Or if someone could point me in the right direction it would be great!
Thanks!
Posted: Tue Jul 11, 2006 3:21 pm
by jamiel
This is a tired discussion. Google for "preg_match e-mail address" or "regex e-mail address" or search this forum.
Posted: Tue Jul 11, 2006 3:28 pm
by Ollie Saunders
That's it as a JS literal:
Code: Select all
/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}/i
Posted: Tue Jul 11, 2006 3:47 pm
by tecktalkcm0391
I want to do something like this:
http://www.mailtester.com/test.php?emai ... sdjalf.com
but it would just return valid or not valid.
Posted: Tue Jul 11, 2006 3:50 pm
by Luke
Why not just check that it is formed like an email address with regex? Is it absolutely VITAL that the email is a REAL email address... cuz there is no way to know that for sure. (that I know of)
Posted: Tue Jul 11, 2006 3:52 pm
by tecktalkcm0391
Posted: Tue Jul 11, 2006 3:53 pm
by Ollie Saunders
Why not just check that it is formed like an email address with regex? Is it absolutely VITAL that the email is a REAL email address... cuz there is no way to know that for sure. (that I know of)
Yeah. I'm not sure how that mailtester site works but I bet it is flawed. Regex is generally the best you can do with any reliability as far as I know.
Posted: Tue Jul 11, 2006 3:57 pm
by bokehman
The Ninja Space Goat wrote:Why not just check that it is formed like an email address with regex? Is it absolutely VITAL that the email is a REAL email address... cuz there is no way to know that for sure. (that I know of)
Well you could send it a token and wait for the response.
I've got a tool
here that connects to the remote server to see if it will accept mail for a particular address but even this doesn't prove the address is good... only that the mail server will accept mail for it.
Posted: Tue Jul 11, 2006 4:09 pm
by tecktalkcm0391
OK, well could you send me the codes for it cause that would be awsome!
Posted: Tue Jul 11, 2006 4:09 pm
by Luke
nice... you built that? That's pretty cool.
Posted: Tue Jul 11, 2006 4:10 pm
by tecktalkcm0391
Yeah he did. I get your point now that I played around with it. Still, How did you do that ?
Posted: Tue Jul 11, 2006 4:25 pm
by RobertGonzalez
bokehman wrote:I've got a tool
here that connects to the remote server to see if it will accept mail for a particular address but even this doesn't prove the address is good... only that the mail server will accept mail for it.
That is freaking sweet! Have you ever opened that code or published it? Me thinks it would be a nice fit in the
PHPClasses.org library.
Posted: Tue Jul 11, 2006 4:26 pm
by Chris Corbyn
ole wrote:Why not just check that it is formed like an email address with regex? Is it absolutely VITAL that the email is a REAL email address... cuz there is no way to know that for sure. (that I know of)
Yeah. I'm not sure how that mailtester site works but I bet it is flawed. Regex is generally the best you can do with any reliability as far as I know.
It will be flawed. I can only see a few ways to do it.
1. Send an email and ask for a reply
2. Hope the server informs you if the RCPT envelope doesn't exist before DATA is sent
3. Hope the server accepts VRFY as a command
The latter two are almost certainly not going to work these days. Number 1 is the generally accepted way to do it.
Posted: Tue Jul 11, 2006 4:27 pm
by RobertGonzalez
If you want to use RegEx, have a look at
RegExpLib.com's Email Expressions.
Posted: Tue Jul 11, 2006 4:28 pm
by Luke
d11wtq wrote:1. Send an email and ask for a reply
I am so bad at forgetting to think about the MOST OBVIOUS solution there is. Wow. Thanks for the smack in the head man. Geeze!