News for hackers. Stuff that matters.
Re:Real Email Validation by fein on Monday March 18, 2013 @09:46AM (#5394079)
Here's a secret:

regex: /^(.+)\@(.+)\.(.+)$/

maxlen: 254, minlen:5

Aside from sending your verification email, that's all you need.

Re:Real Email Validation by Sephr on Monday March 18, 2013 @11:02AM (#5394576)
n@ai (Ian Goldberg's real, valid email address) is rejected by this by your minlength and by the subdomain requirement. You're better off just checking for an @ and leaving the rest to your smtp library.
Re:Real Email Validation by noneTheHacker on Monday March 18, 2013 @10:55AM (#5394522)
That excludes TLD emails like postbox@com

I have never come across someone using one but it is valid. I would actually hate to see someone try to use one. I come across enough issues trying to use '+' in my gmail email address.

http://en.wikipedia.org/wiki/Email_address#Valid_email_addre...

Re:Real Email Validation by nicktelford on Monday March 18, 2013 @12:01PM (#5394975)
It's not just TLDs. Machine aliases are also perfectly valid in e-mail addresses, e.g. "root@localhost", "fred@finance" etc.

This might not be practical in a majority of applications (you're hardly going to sign up to 3rd party services using an alias to a machine on your local network) but if you're building a generic e-mail address validation library, it's an edge case you cannot ignore.

Re:Real Email Validation by threedaymonk on Monday March 18, 2013 @12:25PM (#5395166)
I just check for /.@./, which catches obvious errors like leaving out the email, or typing something in the wrong field. Beyond that, there's no point making assumptions (like "all domains have a dot").
Re:Real Email Validation by astrodust on Monday March 18, 2013 @12:32PM (#5395230)
Today all domains have at least one dot in them. If, at some point in the future, you're allowed to have "jimmy@nike", directly at a TLD, we'll have bigger fish to fry than that.
Re:Real Email Validation by baudehlo on Monday March 18, 2013 @02:18PM (#5396094)
Re:Real Email Validation by astrodust on Monday March 18, 2013 @02:42PM (#5396272)
Edge case city, there are perhaps a handful of people in the world without a dot in their domain, but yes, technically correct.

The thing is, for every legitimate bob@ai there are millions of erroneous bob@gmail mistakes that would slip through. At the very least a warning should be presented.

Re:Real Email Validation by ceejayoz on Monday March 18, 2013 @09:59AM (#5394167)
Re:Real Email Validation by saurik on Monday March 18, 2013 @10:12AM (#5394241)
Re:Real Email Validation by pythonist on Monday March 18, 2013 @10:26AM (#5394334)
I believe that this part is using the Django's pattern matching:

super(EmailValidator, self).__call__(value)

Just tried it. It works!

Re:Real Email Validation by micampe on Monday March 18, 2013 @10:28AM (#5394353)
Are single letter domain and tlds allowed?
Re:Real Email Validation by fein on Monday March 18, 2013 @10:36AM (#5394397)
yep, thats why we do a check for a min of 5 chars:

[email protected]

edit: the regex should pick this up by default anyway, given its looking for .+ and not .*, but my validation libs have the min and max length built in as well.

Re:Real Email Validation by micampe on Monday March 18, 2013 @01:24PM (#5395647)
I meant to ask if they are valid in the IETF sense, not in your regex.

Turns out that single letter second level domains are allowed but they are reserved in some TLDs http://en.wikipedia.org/wiki/Single-letter_second-level_doma...

On the other hand, no single letter TLD exists http://data.iana.org/TLD/tlds-alpha-by-domain.txt

And I also just found out in that list that there are IDN TLDs (see punycode toward the end of the list), I didn’t know that. Full decoded list: http://mct.verisign-grs.com/convertServlet?input=XN--0ZWM56D...

I wonder how many validators fail on these.