Live data from Hacker News

Stop Validating Email Addresses With Your Complex Regexes

davidcelis.com

21–25 of 25 posts

Re: Stop Validating Email Addresses With Your Complex Regexes

#21
post #2

There's got to be a bug because this was on the front page 6 days ago: http://news.ycombinator.com/item?id=4486108 Well the link in the previous post had a trailing slash.

So to sum up the comments on the previous submission: 1) Someone did make a fully compliant Regex https://github.com/larb/email_address_validator 2) Lots of people (including the author http://news.ycombinator.com/item?id=4486264 ) think that you should at least validate that the '@' is somewhere to avoid username / email mixups 3) If your regex fails for foo+tag@something.com lots of people get pissed. I learned you…

Yes.

5) Do some basic validation. If it fails, ask the user: Are you sure this email address is correct? If they say yes, then allow it anyway.

This lets you catch all the typos, without annoying people with more complicated email addresses.

Re: Stop Validating Email Addresses With Your Complex Regexes

#22

What about just checking if a MX record exists?

That verifies the domain, but not the actual mailbox. One possibility would be to lookup the MX, then connect to the remote MTA and ask it directly if the mailbox is valid. But that seems a bit like over-engineering.

It's also possible that the email server is down at the moment, but will come back up later.

Re: Stop Validating Email Addresses With Your Complex Regexes

#23
One suggestion I would add: Let them in right now, and confirm later. Sites that require you to wait for an email, click a validation link etc... have a higher barrier to entry. Sometimes email is slow, sometimes it ends up in spam, etc...

Just let the users in at first to poke around before forcing them to validate their email. After a day or two (or maybe to access certain features) remind them they need to confirm that email they got if they haven't already. Yes, some people may try your product and you won't have their real email address, the the ROI on spamming these people later is probably not worth the initial friction.

Re: Stop Validating Email Addresses With Your Complex Regexes

#24
post #2

There's got to be a bug because this was on the front page 6 days ago: http://news.ycombinator.com/item?id=4486108 Well the link in the previous post had a trailing slash.

So to sum up the comments on the previous submission: 1) Someone did make a fully compliant Regex https://github.com/larb/email_address_validator 2) Lots of people (including the author http://news.ycombinator.com/item?id=4486264 ) think that you should at least validate that the '@' is somewhere to avoid username / email mixups 3) If your regex fails for foo+tag@something.com lots of people get pissed. I learned you…

That the solution proposed kills conversion and is unnecessary.
Post reply on HN