Skip to content

Instantly share code, notes, and snippets.

@sloanlance
Last active December 14, 2016 22:39
Show Gist options
  • Save sloanlance/12970ce2e86fb5d3318c38d51c218427 to your computer and use it in GitHub Desktop.
Save sloanlance/12970ce2e86fb5d3318c38d51c218427 to your computer and use it in GitHub Desktop.

Valid Email Addresses

Many websites attempt to validate email addresses based on formatting rules alone. Often, they use regular expressions which may turn out to be wrong, which is difficult to notice due to their complexity. Attempting to do very much validation of email addresses is usually a mistake and should be avoided.

The most common problem I've seen personally, from the perspective of a website user, is that email addresses containing a plus-sign (+) are considered invalid. For example, an email address like [email protected] is often rejected as invalid. However, that conclusion is incorrect.

As a concrete example, Gmail allows their users to receive email addressed that way. It's helpful to the user, because it allows them to create email sorting rules or filters based on the part of the email address that comes after the +.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment