Validating an email

10-Mar-2015 08:21

validating an email-27

great expectations dating service rated

Feeling happy with my sexy regex, I deployed it, moved onto something else and never gave it another thought.

Then a few weeks later, I got an email from the client saying that one of their users couldn't create an account on the system.

It’s surprisingly easy, and you’re probably already doing it anyway. If you’re going to send an activation email to users, why bother using a gigantic regular expression?

Think about it this way: I register for your website under the email address . That’s probably going to bounce off of the illustrious mail daemon, but the formatting is fine; it’s a valid email address.

And to that end, you don't really need a complicated regular expression. In fact, it's probably better to validate email on the client side, but still allow the user to submit the email even if your validation thinks it's invalid (maybe with minimal server-side validation such as /@/).

You just need one that recognizes when something vaguely along the lines of [email protected] If ensuring that your user enters a valid email is valid is important to your app, then send them a confirmation email. Lets look at a few common examples that I collected(sources are in the table below). And since I think it's much worse to reject a valid emails than to accept an invalid one, that just leaves us with one of the first two. That way you can give them a helpful hint if it looks like they've entered an invalid email, but still allow the people with unusual emails to submit them.

a "personal_info" and a domain, that is [email protected]

The length of the personal_info part may be up to 64 characters long and domain name may be up to 253 characters. The personal_info part contains the following ASCII characters.

validating an email-35

Webcam direct sex

Here's a quick 'n' dirty script to check a few email validation regular expressions. Don’t worry if you didn’t follow my previous tutorial, I will start from scratch again!