E-mail Checking
Moderator: General Moderators
- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
E-mail Checking
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!
Or if someone could point me in the right direction it would be great!
Thanks!
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
That's it as a JS literal:
Code: Select all
/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}/i- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
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.
http://www.mailtester.com/test.php?emai ... sdjalf.com
but it would just return valid or not valid.
- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
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.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.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)
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.
- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
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.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.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
It will be flawed. I can only see a few ways to do it.ole wrote: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.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)
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.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
If you want to use RegEx, have a look at RegExpLib.com's Email Expressions.