![]() |
Checking valid Email Addresses using RegExp (and?)
Hey guys,
For my CMS, I am using the Revised RegEx function from Matt83. Thanks a bunch Matt! Love the work, also thanks to Salathe for the creds and Adam for the sharp eye noticing the {3,3} - {3}. Notice that I am -NOT- a RegEx specialist. To be honest, I suck at it. Since it's for my CMS, it's gotta be pretty fool-fail proof. I am going to link it to a dns record database using the functions supplied by PHP itself. (defined in the installation to use it. IF it takes too long, you can't use it) Now the hard part. The RegEx. I want to use it everywhere, so it has to be 100% (or at least top notch) perfect. Currently I use this RegEx PHP Code:
info@markernst.com » markernst.com) Do you guys think this is pretty safe? |
To start us off, you probably want
{2,6} at the end because of the .org.uk and .museum extensions. It seems to function pretty well for me, though. |
Out of interest, why would you need such a stringent e-mail address check? Assuming that you want it to be a correct e-mail address so that you can e-mail your users, it might be worth implementing an e-mail confirmation system where you e-mail your new registrations and they then click the link to confirm their e-mail. This would catch the people who just enter junk but regex valid email addresses (ie, bill@microsoft.com) when registering.
Unfortunately, a problem I ran across recently was users using sites like MintEmail - Disposable/Temporary Email Address (temporary 4hour throwaway e-mail addresses) when registering - short of banning all these domains I have yet to find a solution to this. Alan |
Why go so far to check to make sure the e-mail is correct?
There is only so far you can go until it is just a bother to users. I suggest reading some articles people have made on image protection, you would find them interesting, and valid to this subject. If you want to be a wise ass, check to make sure the domain they are registering is actually a domain. This can go farther than regex. |
The main reason for ensuring a correct / working e-mail address is for marketing. A valid e-mail address is like gold nowadays whether you plan on selling the addresses, sending out adverts in your usual newsletter or just as a future resource.
One effective way of acheiving this and one I plan on using more in the future is to scrap login names completely and have users login using their e-mail address / password. If you want to take this one further, you can send a randomly generated password to the e-mail account on registration rather than let the user choose their own. This way your mailing list is going to be about as accurate as it can be. But... as usual - those lovely users of ours have solved this problem already: :) Bugmenot.com - login with these free web passwords to bypass compulsory registration Alan |
Here I've compiled a list of the most popular dispoable emails it's already in an array for easy use...it'll be easy enough to check the email's domain against the array.
PHP Code:
|
Thanks for that Andres, I'll be making use of your list in future :)
Alan. |
Quote:
Talking of which though, concerning the code, I only check for the basic email structure. I'm not so particular as to craft an extensive regex string because at the end of the day, it could still be a false email address. There is a function called checkdnsrr but I remember having some problems with that. You'll really need to check both MX and A records, as relying on the MX record being present is not a good idea, I found. For whatever reason, I am not sure on the specifics.The best way is to really enforce users to activate their account. That way at least the email address has to be a valid email address. Whether that's a spam address (such as the notorious mail.ru spam), is immaterial because that's the responsibility for another part of the system, though predominantly that responsibility lies at the fingers of the users and the administrators. |
Long one, so here we go.
Quote:
People who use my CMS want HONEST customers/people. If you don't like it, don't register. Quote:
Quote:
Quote:
Quote:
BugMeNot.com is a fair site, for sure. I've heard about it but never tended to use it. It's English and most Dutchmen are really against registering on foreign sites. I on the other hand, am not. Quote:
Mark |
On a note so relevant note..
I'm personally annoyed by BugMeNot and am writing a function to scan for my site on bugmenot and take the users their and ban them. |
When you finish up that one, post it! :-D
|
PHP Code:
Notes -Bugmenot.com generates different pages for yeah.com - Only the best links ... and foo.com -I haven't actually tested the getCURL function because I don't have the extension installed, I was using file_get_contents from a test file. -it returns an array containing all the usernames |
I've had a stab at it as well. Call it the official TalkPHP Bug Me Not Killer! With added cyanide :-) !
php Code:
|
| All times are GMT. The time now is 08:17 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0