stackoverflow.com
Open in
urlscan Pro
172.64.155.249
Public Scan
URL:
https://stackoverflow.com/questions/2049502/what-characters-are-allowed-in-an-email-address
Submission: On June 21 via api from DE — Scanned from DE
Submission: On June 21 via api from DE — Scanned from DE
Form analysis
4 forms found in the DOMPOST /users/signup?ssrc=undefined&returnurl=https%3A%2F%2Fstackoverflow.com%2Fusers%2Fafter-signup%2Foauth-only
<form class="flex--item" action="/users/signup?ssrc=undefined&returnurl=https%3A%2F%2Fstackoverflow.com%2Fusers%2Fafter-signup%2Foauth-only" method="POST" target="oauth-frame"><input type="hidden" name="fkey"
value="65445e01ac084c585d80a6482ac2510fced0fc375386300173c0ee5902e3bed8"> <input type="hidden" name="legalLinksShown" value="1"> <input type="hidden" name="ssrc" value="undefined"> <input type="hidden" name="oauth_version" value="2.0"> <input
type="hidden" name="oauth_server">
<div class="d-flex fd-column gy12"><button class="s-btn w100 s-btn__google" type="submit" data-testid="signup-google" data-provider="Google">
<div class="d-flex ai-center jc-center gx8"><svg aria-hidden="true" class="native svg-icon iconGoogle" width="18" height="18" viewBox="0 0 18 18">
<path fill="#4285F4" d="M16.51 8H8.98v3h4.3c-.18 1-.74 1.48-1.6 2.04v2.01h2.6a7.8 7.8 0 0 0 2.38-5.88c0-.57-.05-.66-.15-1.18"></path>
<path fill="#34A853" d="M8.98 17c2.16 0 3.97-.72 5.3-1.94l-2.6-2a4.8 4.8 0 0 1-7.18-2.54H1.83v2.07A8 8 0 0 0 8.98 17"></path>
<path fill="#FBBC05" d="M4.5 10.52a4.8 4.8 0 0 1 0-3.04V5.41H1.83a8 8 0 0 0 0 7.18z"></path>
<path fill="#EA4335" d="M8.98 4.18c1.17 0 2.23.4 3.06 1.2l2.3-2.3A8 8 0 0 0 1.83 5.4L4.5 7.49a4.8 4.8 0 0 1 4.48-3.3"></path>
</svg> Sign up with Google</div>
</button><button class="s-btn w100 s-btn__google" type="submit" data-testid="signup-github" data-provider="GitHub">
<div class="d-flex ai-center jc-center gx8"><svg aria-hidden="true" class="native svg-icon iconGitHub" width="18" height="18" viewBox="0 0 18 18">
<path fill="#010101"
d="M9 1a8 8 0 0 0-2.53 15.59c.4.07.55-.17.55-.38l-.01-1.49c-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.4 7.4 0 0 1 4 0c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48l-.01 2.2c0 .21.15.46.55.38A8.01 8.01 0 0 0 9 1">
</path>
</svg> Sign up with GitHub</div>
</button></div>
</form>
POST /users/signup?ssrc=undefined&returnurl=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F2049502%2Fwhat-characters-are-allowed-in-an-email-address
<form id="signup-modal-signup-form" class="mt32 d-flex fd-column gy16" action="/users/signup?ssrc=undefined&returnurl=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F2049502%2Fwhat-characters-are-allowed-in-an-email-address" method="POST"><input
type="hidden" name="fkey" value="65445e01ac084c585d80a6482ac2510fced0fc375386300173c0ee5902e3bed8"> <input type="hidden" name="legalLinksShown" value="1"> <input type="hidden" name="ssrc" value="undefined">
<div class="flex--item d-flex fd-column gs4 gsy svelte-1rlgrxv"><label class="flex--item s-label" for="signup-modal-email">Email</label>
<div class="d-flex ps-relative"><input class="s-input" id="signup-modal-email" size="30" maxlength="100" name="email" autocomplete="off"></div>
</div>
<div class="flex--item d-flex fd-column gs4 gsy svelte-1rlgrxv"><label class="flex--item s-label" for="signup-modal-password">Password</label>
<div class="d-flex ps-relative"><input id="signup-modal-password" class="flex--item s-input" type="password" autocomplete="new-password" name="password" placeholder="8+ characters (at least 1 letter & 1 number)"> <button type="button"
class="show-hide-password svelte-1rlgrxv"><svg aria-hidden="true" class="svg-icon iconEyeOff" width="18" height="18" viewBox="0 0 18 18">
<path
d="m5.02 9.44-2.22 2.2C1.63 10.25 1 9 1 9s3-6 8.06-6q1.13.01 2.12.38L9.5 5.03 9 5a4 4 0 0 0-3.98 4.44m2.03 3.05A4 4 0 0 0 13 9q-.01-1.1-.54-2l-1.51 1.54q.05.22.05.46a2 2 0 0 1-2.44 1.95zm7.11-7.22A15 15 0 0 1 17 9s-3 6-7.94 6c-1.31 0-2.48-.4-3.5-1l-1.97 2L2 14.41 14.59 2 16 3.41z">
</path>
</svg></button></div>
</div>
<div class="flex--item d-flex gs4 gsy fd-column svelte-1rlgrxv"><button class="flex--item s-btn s-btn__filled mt12 svelte-1rlgrxv" id="signup-modal-submit-button" name="submit-button" type="submit">Sign up</button>
<p class="flex--item s-input-message d-none svelte-1rlgrxv" aria-hidden="true" aria-live="assertive"></p>
</div>
</form>
POST /users/auth/gcp?ssrc=google-one-tap&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f2049502%2fwhat-characters-are-allowed-in-an-email-address
<form id="one-tap-form" method="post" action="/users/auth/gcp?ssrc=google-one-tap&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f2049502%2fwhat-characters-are-allowed-in-an-email-address"><input type="hidden" name="fKey"
value="65445e01ac084c585d80a6482ac2510fced0fc375386300173c0ee5902e3bed8"> <input type="hidden" name="googleIdToken" value=""></form>
/search
<form id="search" role="search" action="/search" class="s-topbar--searchbar js-searchbar " autocomplete="off">
<div class="s-topbar--searchbar--input-group">
<input name="q" type="text" role="combobox" placeholder="Search…" value="" autocomplete="off" maxlength="240" class="s-input s-input__search js-search-field wmn1 " aria-label="Search" aria-controls="top-search" data-controller="s-popover"
data-action="focus->s-popover#show" data-s-popover-placement="bottom-start" aria-expanded="false">
<svg aria-hidden="true" class="s-input-icon s-input-icon__search svg-icon iconSearch" width="18" height="18" viewBox="0 0 18 18">
<path d="m18 16.5-5.14-5.18h-.35a7 7 0 1 0-1.19 1.19v.35L16.5 18l1.5-1.5ZM12 7A5 5 0 1 1 2 7a5 5 0 0 1 10 0Z"></path>
</svg>
<div class="s-popover p0 wmx100 wmn4 sm:wmn-initial js-top-search-popover" id="top-search" role="menu">
<div class="s-popover--arrow"></div>
<div class="s-popover--content">
<div class="js-spinner p24 d-flex ai-center jc-center d-none">
<div class="s-spinner s-spinner__sm fc-orange-400">
<div class="v-visible-sr">Loading…</div>
</div>
</div>
<span class="v-visible-sr js-screen-reader-info"></span>
<div class="js-ac-results overflow-y-auto hmx3 d-none"></div>
<div class="js-search-hints" aria-describedby="Tips for searching"></div>
</div>
</div>
</div>
</form>
Text Content
JOIN STACK OVERFLOW By clicking “Sign up”, you agree to our terms of service and acknowledge you have read our privacy policy. Sign up with Google Sign up with GitHub OR Email Password Sign up Already have an account? Log in Skip to main content Stack Overflow 1. About 2. Products 3. OverflowAI 1. Stack Overflow Public questions & answers 2. Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers 3. Talent Build your employer brand 4. Advertising Reach developers & technologists worldwide 5. Labs The future of collective knowledge sharing 6. About the company Loading… 1. CURRENT COMMUNITY * Stack Overflow help chat * Meta Stack Overflow YOUR COMMUNITIES Sign up or log in to customize your list. MORE STACK EXCHANGE COMMUNITIES company blog 2. 3. Log in 4. Sign up How are we doing? Please help us improve Stack Overflow. Take our short survey 1. 1. Home 2. Questions 3. Tags 4. 5. Users 6. Companies 7. Labs 8. Jobs 9. Discussions 10. Collectives 11. Communities for your favorite technologies. Explore all Collectives 2. Teams Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams Create a free Team 3. Teams 4. Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams COLLECTIVES™ ON STACK OVERFLOW Find centralized, trusted content and collaborate around the technologies you use most. Learn more about Collectives Teams Q&A for work Connect and share knowledge within a single location that is structured and easy to search. Learn more about Teams Get early access and see previews of new features. Learn more about Labs How are we doing? Take our short survey WHAT CHARACTERS ARE ALLOWED IN AN EMAIL ADDRESS? Ask Question Asked 14 years, 5 months ago Modified 2 months ago Viewed 1.3m times Report this ad This question shows research effort; it is useful and clear 860 Save this question. Show activity on this post. I'm not asking about full email validation. I just want to know what are allowed characters in user-name and server parts of email address. This may be oversimplified, maybe email adresses can take other forms, but I don't care. I'm asking about only this simple form: user-name@server (e.g. wild.wezyr@best-server-ever.com) and allowed characters in both parts. * forms * email * email-validation * email-address Share Share a link to this question Copy linkCC BY-SA 3.0 Improve this question Follow Follow this question to receive notifications edited Mar 19, 2017 at 10:06 kevinarpe 21k2727 gold badges131131 silver badges161161 bronze badges asked Jan 12, 2010 at 14:13 WildWezyrWildWezyr 10.5k66 gold badges2424 silver badges2828 bronze badges 22 * 270 The + is allowed. It drives me nuts when web sites don't allow it because my email has a + in it and so many sites don't allow it. – Dan Herbert Commented Jan 12, 2010 at 14:16 * 12 Earlier question covering the same material: stackoverflow.com/questions/760150/. The sad thing is, even though that question is almost 8 months older than this one, the older question has much better answers. Almost all the answers below were already out of date when they were originally posted. See Wikipedia entry (and don't worry, it has relevant official references). – John Y Commented Jul 20, 2012 at 20:56 * 29 Contrary to several answers, spaces are allowed in the local part of email addresses, if quoted. "hello world"@example.com is valid. – Quitting Due To Antisemitism Commented Jul 8, 2014 at 6:34 * 13 @LaraRuffleColes - For Gmail, when you create an email account, it doesn't allow you to create addresses containing a "+" sign. The "+" sign ("Plus-addressing") allows anyone with a Gmail address to add a "+" sign followed by a "string" to the end of their username to create an "alternate" ("alias") email address to use for their account. Example: "example@gmail.com", "example+tag@gmail.com". A typical (and probably "Primary") use of this is to be able to create alias email addresses for your account which allow you to tag and filter incoming email messages, theoretically filtered by sender. – Kevin Fegan Commented Sep 26, 2016 at 17:49 * 10 @Andrew The reverse is much more common. If a site can't be trusted to allow proper email addresses, I don't trust them to handle my personal information. – Dan Herbert Commented Apr 6, 2018 at 16:15 | Show 17 more comments 18 ANSWERS 18 Sorted by: Reset to default Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first) This answer is useful 1007 Save this answer. +100 This answer has been awarded bounties worth 100 reputation by WildWezyr Show activity on this post. See RFC 5322: Internet Message Format and, to a lesser extent, RFC 5321: Simple Mail Transfer Protocol. RFC 822 also covers email addresses, but it deals mostly with its structure: addr-spec = local-part "@" domain ; global address local-part = word *("." word) ; uninterpreted ; case-preserved domain = sub-domain *("." sub-domain) sub-domain = domain-ref / domain-literal domain-ref = atom ; symbolic reference where an atom and word are defined as ; ( Octal, Decimal.) CHAR = <any ASCII character> ; ( 0-177, 0.-127.) CTL = <any ASCII control ; ( 0- 37, 0.- 31.) character and DEL> ; ( 177, 127.) specials = "(" / ")" / "<" / ">" / "@" ; Must be in quoted- / "," / ";" / ":" / "\" / <"> ; string, to use / "." / "[" / "]" ; within a word. atom = 1*<any CHAR except specials, SPACE and CTLs> word = atom / quoted-string And as usual, Wikipedia has a decent article on email addresses: > The local-part of the email address may use any of these ASCII characters: > > * uppercase and lowercase Latin letters A to Z and a to z; > * digits 0 to 9; > * special characters !#$%&'*+-/=?^_`{|}~; > * dot ., provided that it is not the first or last character unless quoted, > and provided also that it does not appear consecutively unless quoted (e.g. > John..Doe@example.com is not allowed but "John..Doe"@example.com is > allowed); > * space and "(),:;<>@[\] characters are allowed with restrictions (they are > only allowed inside a quoted string, as described in the paragraph below, > and in addition, a backslash or double-quote must be preceded by a > backslash); > * comments are allowed with parentheses at either end of the local-part; e.g. > john.smith(comment)@example.com and (comment)john.smith@example.com are > both equivalent to john.smith@example.com. In addition to ASCII characters, as of 2012 you can use international characters above U+007F, encoded as UTF-8 as described in the RFC 6532 spec and explained on Wikipedia. Note that as of 2019, these standards are still marked as Proposed, but are being rolled out slowly. The changes in this spec essentially added international characters as valid alphanumeric characters (atext) without affecting the rules on allowed & restricted special characters like !# and @:. For validation, see Using a regular expression to validate an email address. The domain part is defined as follows: > The Internet standards (Request for Comments) for protocols mandate that > component hostname labels may contain only the ASCII letters a through z (in a > case-insensitive manner), the digits 0 through 9, and the hyphen (-). The > original specification of hostnames in RFC 952, mandated that labels could not > start with a digit or with a hyphen, and must not end with a hyphen. However, > a subsequent specification (RFC 1123) permitted hostname labels to start with > digits. No other symbols, punctuation characters, or blank spaces are > permitted. Share Share a link to this answer Copy linkCC BY-SA 4.0 Improve this answer Follow Follow this answer to receive notifications edited Mar 30 at 8:56 theking2 2,51022 gold badges3333 silver badges4242 bronze badges answered Jan 12, 2010 at 14:15 Anton GogolevAnton Gogolev 115k3939 gold badges203203 silver badges291291 bronze badges 20 * 25 @WildWzyr, It's not that simple. Email addresses have a lot of rules for what is allowed. It's simpler to refer to the spec than to list out all of them. If you want the complete Regex, check here to get an idea of why it's not so simple: regular-expressions.info/email.html – Dan Herbert Commented Jan 12, 2010 at 14:20 * 6 there is no simple list, just because you want something simple doesn't mean it will be so. some characters can only be in certain locations and not in others. you can't have what you want all the time. – user177800 Commented Jan 12, 2010 at 14:28 * 16 @WildWezyr Well, the full-stop character is allowed in the local-part. But not at the start or end. Or with another full-stop. So the answer IS NOT as simple as just a list of allowed characters, there are rules as to how those characters may be used - .ann..other.@example.com is not a valid email address, but ann.other@example.com is, even though both use the same characters. – Mark Pim Commented Jan 12, 2010 at 14:30 * 14 Also, remember that with internationalized domain names coming in, the list of allowed characters will explode. – Chinmay Kanchi Commented Jan 12, 2010 at 15:18 * 55 This is no longer the valid answer, due to internationalized addresses. See Mason's answer. – ZacharyP Commented Dec 6, 2011 at 17:59 | Show 15 more comments This answer is useful 401 Save this answer. Show activity on this post. Watch out! There is a bunch of knowledge rot in this thread (stuff that used to be true and now isn't). To avoid false-positive rejections of actual email addresses in the current and future world, and from anywhere in the world, you need to know at least the high-level concept of RFC 3490, "Internationalizing Domain Names in Applications (IDNA)". I know folks in US and A often aren't up on this, but it's already in widespread and rapidly increasing use around the world (mainly the non-English dominated parts). The gist is that you can now use addresses like mason@日本.com and wildwezyr@fahrvergnügen.net. No, this isn't yet compatible with everything out there (as many have lamented above, even simple qmail-style +ident addresses are often wrongly rejected). But there is an RFC, there's a spec, it's now backed by the IETF and ICANN, and--more importantly--there's a large and growing number of implementations supporting this improvement that are currently in service. I didn't know much about this development myself until I moved back to Japan and started seeing email addresses like hei@やる.ca and Amazon URLs like this: http://www.amazon.co.jp/エレクトロニクス-デジタルカメラ-ポータブルオーディオ/b/ref=topnav_storetab_e?ie=UTF8&node=3210981 I know you don't want links to specs, but if you rely solely on the outdated knowledge of hackers on Internet forums, your email validator will end up rejecting email addresses that non-English-speaking users increasingly expect to work. For those users, such validation will be just as annoying as the commonplace brain-dead form that we all hate, the one that can't handle a + or a three-part domain name or whatever. So I'm not saying it's not a hassle, but the full list of characters "allowed under some/any/none conditions" is (nearly) all characters in all languages. If you want to "accept all valid email addresses (and many invalid too)" then you have to take IDN into account, which basically makes a character-based approach useless (sorry), unless you first convert the internationalized email addresses (dead since September 2015, used to be like this—a working alternative is here) to Punycode. After doing that you can follow (most of) the advice above. Share Share a link to this answer Copy linkCC BY-SA 4.0 Improve this answer Follow Follow this answer to receive notifications edited Oct 21, 2020 at 9:03 David Veszelovszki 2,72211 gold badge2525 silver badges2424 bronze badges answered Jan 15, 2010 at 12:01 MasonMason 5,21144 gold badges2626 silver badges2424 bronze badges 9 * 20 Right; behind the scenes, the domain names are still just ASCII. But, if your web app or form accepts user-entered input, then it needs to perform the same job that the web browser or mail client does when the user inputs an IDN hostname: to convert the user input into DNS-compatible form. Then validate. Otherwise, these internationalized email addresses will not pass your validation. (Converters like the one I linked to only modify the non-ASCII characters they are given, so it is safe to use them on non-internationalized email addresses (those are just returned unmodified).) – Mason Commented Jan 15, 2010 at 13:55 * 3 For Javascript devs, I'm now researching methods of doing this, and Punycode.js seems to be the most complete and polished solution. – wwaawaw Commented Oct 7, 2012 at 7:41 * 5 Note that Internationalized Email (as currently defined) does not convert non-ASCII addresses using punycode or similar, instead extending large portions of the SMTP protocol itself to use UTF8. – IMSoP Commented May 26, 2014 at 21:30 * 4 Am I missing something or does this fail to answer the question? I am reading 'the other answer is wrong, you need to accept more characters' but then fails to state which extra characters. I also couldn't (easily) see in that RFC whether it means all Unicode code points or just the BMP. – Samuel Harmer Commented Feb 5, 2017 at 18:32 * 3 This seems to be on the right track to being the correct answer. I bet it would get a lot more votes if you included specifics about reserved and allowed characters. – Sean Commented Mar 17, 2017 at 18:20 | Show 4 more comments This answer is useful 108 Save this answer. Show activity on this post. The format of e-mail address is: local-part@domain-part (max. 64@255 characters, no more 256 in total). The local-part and domain-part could have different set of permitted characters, but that's not all, as there are more rules to it. In general, the local part can have these ASCII characters: * lowercase Latin letters: abcdefghijklmnopqrstuvwxyz, * uppercase Latin letters: ABCDEFGHIJKLMNOPQRSTUVWXYZ, * digits: 0123456789, * special characters: !#$%&'*+-/=?^_`{|}~, * dot: . (not first or last character or repeated unless quoted), * space punctuations such as: "(),:;<>@[\] (with some restrictions), * comments: () (are allowed within parentheses, e.g. (comment)john.smith@example.com). Domain part: * lowercase Latin letters: abcdefghijklmnopqrstuvwxyz, * uppercase Latin letters: ABCDEFGHIJKLMNOPQRSTUVWXYZ, * digits: 0123456789, * hyphen: - (not first or last character), * can contain IP address surrounded by square brackets: jsmith@[192.168.2.1] or jsmith@[IPv6:2001:db8::1]. These e-mail addresses are valid: * prettyandsimple@example.com * very.common@example.com * disposable.style.email.with+symbol@example.com * other.email-with-dash@example.com * x@example.com (one-letter local part) * "much.more unusual"@example.com * "very.unusual.@.unusual.com"@example.com * "very.(),:;<>[]\".VERY.\"very@\ \"very\".unusual"@strange.example.com * example-indeed@strange-example.com * admin@mailserver1 (local domain name with no top-level domain) * #!$%&'*+-/=?^_`{}|~@example.org * "()<>[]:,;@\\"!#$%&'-/=?^_`{}| ~.a"@example.org * " "@example.org (space between the quotes) * example@localhost (sent from localhost) * example@s.solutions (see the List of Internet top-level domains) * user@com * user@localserver * user@[IPv6:2001:db8::1] And these examples of invalid: * Abc.example.com (no @ character) * A@b@c@example.com (only one @ is allowed outside quotation marks) * a"b(c)d,e:f;gi[j\k]l@example.com (none of the special characters in this local part are allowed outside quotation marks) * just"not"right@example.com (quoted strings must be dot separated or the only element making up the local part) * this is"not\allowed@example.com (spaces, quotes, and backslashes may only exist when within quoted strings and preceded by a backslash) * this\ still\"not\allowed@example.com (even if escaped (preceded by a backslash), spaces, quotes, and backslashes must still be contained by quotes) * john..doe@example.com (double dot before @); (with caveat: Gmail lets this through) * john.doe@example..com (double dot after @) * a valid address with a leading space * a valid address with a trailing space Source: Email address at Wikipedia -------------------------------------------------------------------------------- Perl's RFC2822 regex for validating emails: (?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t] )+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?: \r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:( ?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\0 31]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\ ](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+ (?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?: (?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z |(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n) ?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\ r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n) ?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t] )*))*(?:,@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])* )(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t] )+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*) *:(?:(?:\r\n)?[ \t])*)?(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ |\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r \n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?: \r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t ]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031 ]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\]( ?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(? :(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(? :\r\n)?[ \t])*))*\>(?:(?:\r\n)?[ \t])*)|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(? :(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)? [ \t]))*"(?:(?:\r\n)?[ \t])*)*:(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]| \\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<> @,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|" (?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t] )*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\ ".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(? :[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[ \]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000- \031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|( ?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(?:[^()<>@,; :\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([ ^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\" .\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\ ]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\ [\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\ r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\] |\\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?(?:[^()<>@,;:\\".\[\] \0 00-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\ .|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@, ;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(? :[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])* (?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\". \[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[ ^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\] ]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:(?:\r\n)?[ \t])*)(?:,\s*( ?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\ ".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:( ?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[ \["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t ])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t ])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(? :\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+| \Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*|(?: [^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\ ]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\<(?:(?:\r\n) ?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\[" ()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n) ?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<> @,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@, ;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t] )*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\ ".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)? (?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\". \[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?: \r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\[ "()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t]) *))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]) +|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\ .(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z |(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:( ?:\r\n)?[ \t])*))*)?;\s*) > The full regexp for RFC2822 addresses was a mere 3.7k. See also: RFC 822 Email Address Parser in PHP. -------------------------------------------------------------------------------- The formal definitions of e-mail addresses are in: * RFC 5322 (sections 3.2.3 and 3.4.1, obsoletes RFC 2822), RFC 5321, RFC 3696, * RFC 6531 (permitted characters). -------------------------------------------------------------------------------- Related: * The true power of regular expressions Share Share a link to this answer Copy linkCC BY-SA 4.0 Improve this answer Follow Follow this answer to receive notifications edited May 23, 2018 at 11:47 answered Aug 5, 2016 at 10:45 kenorbkenorb 162k9393 gold badges697697 silver badges761761 bronze badges 10 * 23 As an extra caution to would-be implementers of this regex: Don't. Just verify that it folows the format something@something.something and call it a day. – Chris Sobolewski Commented Sep 7, 2017 at 14:41 * 1 While something like this is not maintainable, it is a nice exercise to decode and actually figure out what it does – unjankify Commented Feb 27, 2018 at 16:53 * 9 Madness I say. Who would ever use it in production. There is a point where regular expression should no longer be used. It is far beyond that point. – tomuxmon Commented Jun 14, 2019 at 7:18 * 3 Something I see a lot is "validate according to RFC822". This isn't actually what's usually needed. RFC822 doesn't define addresses that can be sent to; it defines addresses that can appear in messages, which is not the same thing. Addresses that can be sent to is determined in RFC821 (SMTP) and follow-on standards. In particular this spec does not allow comments, excluding addresses like a@abc(bananas)def.com that are valid RFC822 addresses but can't be sent to. For this reason, many email validators are validating against the wrong thing. – Synchro Commented Sep 18, 2020 at 9:02 * 2 @ChrisSobolewski absolutely. The aim of this verification is to help the user, and avoid obvious mistakes (such as forgetting @ or similar). A split on the email against @ and checking if it returns two non zero strings is enough. – WoJ Commented Sep 8, 2023 at 10:00 | Show 5 more comments This answer is useful 26 Save this answer. Show activity on this post. Wikipedia has a good article on this, and the official spec is here. From Wikipdia: > The local-part of the e-mail address may use any of these ASCII characters: > > * Uppercase and lowercase English letters (a-z, A-Z) > * Digits 0 to 9 > * Characters ! # $ % & ' * + - / = ? ^ _ ` { | } ~ > * Character . (dot, period, full stop) provided that it is not the first or > last character, and provided also that it does not appear two or more times > consecutively. > > Additionally, quoted-strings (ie: "John Doe"@example.com) are permitted, thus > allowing characters that would otherwise be prohibited, however they do not > appear in common practice. RFC 5321 also warns that "a host that expects to > receive mail SHOULD avoid defining mailboxes where the Local-part requires (or > uses) the Quoted-string form". Share Share a link to this answer Copy linkCC BY-SA 3.0 Improve this answer Follow Follow this answer to receive notifications edited Oct 7, 2021 at 5:46 CommunityBot 111 silver badge answered Jan 12, 2010 at 14:20 Mike WellerMike Weller 45.6k1515 gold badges133133 silver badges154154 bronze badges 2 * @WildWezyr Valid hostnames, which could be an ip address, FQN, or something resolvable to an local network host. – JensenDied Commented Jan 12, 2010 at 14:36 * Quoted strings were essential for passing through a gateway, remember Banyan Vines? – mckenzm Commented Nov 1, 2018 at 3:43 Add a comment | This answer is useful 18 Save this answer. Show activity on this post. The accepted answer refers to a Wikipedia article when discussing the valid local-part of an email address, but Wikipedia is not an authority on this. IETF RFC 3696 is an authority on this matter, and should be consulted at section 3. Restrictions on email addresses on page 5: > Contemporary email addresses consist of a "local part" separated from a > "domain part" (a fully-qualified domain name) by an at-sign ("@"). The syntax > of the domain part corresponds to that in the previous section. The concerns > identified in that section about filtering and lists of names apply to the > domain names used in an email context as well. The domain name can also be > replaced by an IP address in square brackets, but that form is strongly > discouraged except for testing and troubleshooting purposes. > > The local part may appear using the quoting conventions described below. The > quoted forms are rarely used in practice, but are required for some legitimate > purposes. Hence, they should not be rejected in filtering routines but, should > instead be passed to the email system for evaluation by the destination host. > > The exact rule is that any ASCII character, including control characters, may > appear quoted, or in a quoted string. When quoting is needed, the backslash > character is used to quote the following character. For example > > Abc\@def@example.com > > > is a valid form of an email address. Blank spaces may also appear, as in > > Fred\ Bloggs@example.com > > > The backslash character may also be used to quote itself, e.g., > > Joe.\\Blow@example.com > > > In addition to quoting using the backslash character, conventional > double-quote characters may be used to surround strings. For example > > "Abc@def"@example.com > > "Fred Bloggs"@example.com > > > are alternate forms of the first two examples above. These quoted forms are > rarely recommended, and are uncommon in practice, but, as discussed above, > must be supported by applications that are processing email addresses. In > particular, the quoted forms often appear in the context of addresses > associated with transitions from other systems and contexts; those > transitional requirements do still arise and, since a system that accepts a > user-provided email address cannot "know" whether that address is associated > with a legacy system, the address forms must be accepted and passed into the > email environment. > > Without quotes, local-parts may consist of any combination of alphabetic > characters, digits, or any of the special characters > > ! # $ % & ' * + - / = ? ^ _ ` . { | } ~ > > > period (".") may also appear, but may not be used to start or end the local > part, nor may two or more consecutive periods appear. Stated differently, any > ASCII graphic (printing) character other than the at-sign ("@"), backslash, > double quote, comma, or square brackets may appear without quoting. If any of > that list of excluded characters are to appear, they must be quoted. Forms > such as > > user+mailbox@example.com > > customer/department=shipping@example.com > > $A12345@example.com > > !def!xyz%abc@example.com > > _somename@example.com > > > are valid and are seen fairly regularly, but any of the characters listed > above are permitted. As others have done, I submit a regex that works for both PHP and JavaScript to validate email addresses: /^[a-z0-9!'#$%&*+\/=?^_`{|}~-]+(?:\.[a-z0-9!'#$%&*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-zA-Z]{2,}$/i Share Share a link to this answer Copy linkCC BY-SA 4.0 Improve this answer Follow Follow this answer to receive notifications edited Apr 2, 2022 at 16:04 answered Dec 4, 2015 at 20:35 MacMac 1,5262222 silver badges2828 bronze badges 2 * 1 Technically e-mail addresses are allowed also in TLD, so you may consider changing last group's + to *. OTOH, technically valid address in TLD may be a blank typo, as these addresses are far less common. Spec vs. life… ;-) – Cromax Commented Mar 7, 2023 at 17:06 * @Cromax - exactly. There has to be a happy medium between what we CAN do vs. what is USUALLY done. – Mac Commented Mar 10, 2023 at 22:40 Add a comment | This answer is useful 16 Save this answer. Show activity on this post. You can start from wikipedia article: * Uppercase and lowercase English letters (a-z, A-Z) * Digits 0 to 9 * Characters ! # $ % & ' * + - / = ? ^ _ ` { | } ~ * Character . (dot, period, full stop) provided that it is not the first or last character, and provided also that it does not appear two or more times consecutively. Share Share a link to this answer Copy linkCC BY-SA 2.5 Improve this answer Follow Follow this answer to receive notifications answered Jan 12, 2010 at 14:20 VladimirVladimir 171k3636 gold badges389389 silver badges313313 bronze badges Add a comment | This answer is useful 13 Save this answer. Show activity on this post. Google do an interesting thing with their gmail.com addresses. gmail.com addresses allow only letters (a-z), numbers, and periods(which are ignored). e.g., pikachu@gmail.com is the same as pi.kachu@gmail.com, and both email addresses will be sent to the same mailbox. PIKACHU@gmail.com is also delivered to the same mailbox. So to answer the question, sometimes it depends on the implementer on how much of the RFC standards they want to follow. Google's gmail.com address style is compatible with the standards. They do it that way to avoid confusion where different people would take similar email addresses e.g. *** gmail.com accepting rules *** d.oy.smith@gmail.com (accepted) d_oy_smith@gmail.com (bounce and account can never be created) doysmith@gmail.com (accepted) D.Oy'Smith@gmail.com (bounce and account can never be created) The wikipedia link is a good reference on what email addresses generally allow. http://en.wikipedia.org/wiki/Email_address Share Share a link to this answer Copy linkCC BY-SA 3.0 Improve this answer Follow Follow this answer to receive notifications edited Mar 21, 2014 at 12:01 gaoithe 4,31833 gold badges3232 silver badges3939 bronze badges answered Jan 18, 2012 at 9:34 Angel KohAngel Koh 13.1k77 gold badges6868 silver badges9494 bronze badges 5 * 3 Yea this is a great answer about why Gmail does not allow to CREATE emails with this. But you can send and recieve emails from {john'doe}@my.server with no problem. Tested with hMail server too. – Piotr Kula Commented Jul 15, 2014 at 14:25 * You can test your client by sending an email to {piotr'kula}@kula.solutions - If it works you will get a nice auto reply form it. Otherwise nothing will happen. – Piotr Kula Commented Jul 15, 2014 at 14:29 * 3 Gmail does follow RFC 6530 in the sense that every possible e-mail address allowed by Gmail is valid according to the RFC. Gmail just chooses to further restrict the set of allowable addresses with additional rules, and to make otherwise similar addresses with dots in the local part, optionally followed by "+" and alphanumeric characters, synonymous. – Teemu Leisti Commented Jan 20, 2015 at 13:03 * Google limits the account creation criteria... I imagine they scrub the incoming email account string of the extra "punctuation" and trailing plus prepended alias string sign so that the mail can be routed to the proper account. Easy peasy. In doing so, they effectively don't allow people to create just-bein-a-jerk email addresses so that valid addresses created will often pass simple and most complex validations. – BradChesney79 Commented Feb 8, 2018 at 20:41 * It's not just gmail, Some providers have "relaying filters" that reject certain quoted strings, particularly containing "=" as if they were delimiters. This is to block users from setting up gateways and nesting spam addresses in the private quoted string. "@" is valid but "=@=" is not (considered) valid. – mckenzm Commented Dec 6, 2018 at 2:21 Add a comment | This answer is useful 11 Save this answer. Show activity on this post. Check for @ and . and then send an email for them to verify. I still can't use my .name email address on 20% of the sites on the internet because someone screwed up their email validation, or because it predates the new addresses being valid. Share Share a link to this answer Copy linkCC BY-SA 3.0 Improve this answer Follow Follow this answer to receive notifications answered Jun 11, 2013 at 19:28 Richard MaxwellRichard Maxwell 51855 silver badges77 bronze badges 2 * 9 Even . isn't strictly necessary; I've heard of at least one case of an email address at a top level domain (specifically ua). The address was <name>@ua -- no dot! – user1311045 Commented Nov 28, 2013 at 1:37 * This is pretty much the easiest way not to mess up your validation, because almost everything is allowed, and if something isn't allowed, the recipient's server will let you know. – Avamander Commented Jan 13, 2018 at 11:16 Add a comment | This answer is useful 8 Save this answer. Show activity on this post. The short answer is that there are 2 answers. There is one standard for what you should do. ie behaviour that is wise and will keep you out of trouble. There is another (much broader) standard for the behaviour you should accept without making trouble. This duality works for sending and accepting email but has broad application in life. For a good guide to the addresses you create; see: https://www.jochentopf.com/email/chars.html To filter valid emails, just pass on anything comprehensible enough to see a next step. Or start reading a bunch of RFCs, caution, here be dragons. Share Share a link to this answer Copy linkCC BY-SA 4.0 Improve this answer Follow Follow this answer to receive notifications edited Jun 23, 2021 at 8:50 ygoe 19.6k2525 gold badges119119 silver badges227227 bronze badges answered Mar 1, 2012 at 1:50 Michael JAMESMichael JAMES 9711 silver badge11 bronze badge 3 * 1 The link is gone. What content was there? – ygoe Commented May 26, 2019 at 13:49 * @ygoe yeah site is down, Here is the archive version from ~2012 : web.archive.org/web/20120807105804/https://www.remote.org/… – MilMike Commented Jun 18, 2021 at 11:11 * @MilMike Thank you, from there I found the new URL of that page and edited the answer. – ygoe Commented Jun 23, 2021 at 8:50 Add a comment | This answer is useful 7 Save this answer. Show activity on this post. Name: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#$%&'*+-/=?^_`{|}~. Server: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-. Share Share a link to this answer Copy linkCC BY-SA 3.0 Improve this answer Follow Follow this answer to receive notifications edited Jul 27, 2012 at 17:34 answered Jan 18, 2012 at 9:34 ThinkingStiffThinkingStiff 65.1k3030 gold badges146146 silver badges240240 bronze badges 3 * 5 What about <> and []? E.g. "()<>[]:,;@\\\"!#$%&'-/=?^_{}| ~.a"@example.org`? – kenorb Commented Aug 5, 2016 at 10:11 * 24 Please cite sources. Without sources, this looks like conjecture. – Mathieu K. Commented Feb 14, 2017 at 17:33 * 17 This is out of date, and possibly was never correct. – Jason Harrison Commented Nov 15, 2017 at 17:53 Add a comment | This answer is useful 5 Save this answer. Show activity on this post. A lot many have already attempted answering this question. A lot many have also said that many answers are already outdated. Here is my answer, as things stand in 2022. The answer to the question is obviously not as simple as it has been posed. The proposed standards when it comes to naming of a mailbox name, to be specific, <user-name> in this context, alongwith the interpretations of those RFCs are far and many. For the <user-name> part, Universal Acceptance Steering Group has put up a detailed guideline as to what all constitute an e-mail ID local part in a document titled UASG-028 here. For the <server> part, all the characters mentioned herein "The Unicode Code Points and Internationalized Domain Names for Applications (IDNA)" with the character status "PVALID". Also, the characters with status as "CONTEXTJ" and "CONTEXTO" are valid in certain contexual conditions. Share Share a link to this answer Copy linkCC BY-SA 4.0 Improve this answer Follow Follow this answer to receive notifications answered Jul 7, 2022 at 11:50 ThinkTransThinkTrans 6111 silver badge33 bronze badges Add a comment | This answer is useful 4 Save this answer. Show activity on this post. A good read on the matter. Excerpt: These are all valid email addresses! "Abc\@def"@example.com "Fred Bloggs"@example.com "Joe\\Blow"@example.com "Abc@def"@example.com customer/department=shipping@example.com \$A12345@example.com !def!xyz%abc@example.com _somename@example.com Share Share a link to this answer Copy linkCC BY-SA 3.0 Improve this answer Follow Follow this answer to receive notifications edited Aug 6, 2016 at 9:46 Billal Begueradj 22.1k4545 gold badges122122 silver badges140140 bronze badges answered Jan 6, 2015 at 16:33 Luke MadhangaLuke Madhanga 7,27922 gold badges4747 silver badges4747 bronze badges 3 * 1 I was wondering about the '@' before the domain part. Can that be used? – Saiyaff Farouk Commented Mar 16, 2017 at 12:09 * @SaiyaffFarouk according to the specification, yes. However, most mail providers likely won't allow it as part of their own validation – Luke Madhanga Commented Mar 16, 2017 at 20:04 * that blog lists Joe.\\Blow@example.com without quotes. Is this actually valid ? It doesn't seem clear given the answers here, but I'm asking because I have seen (very rare) cases of DNS SoA rname email strings that contain backslashes. – wesinat0r Commented Apr 22, 2020 at 15:35 Add a comment | This answer is useful -1 Save this answer. Show activity on this post. The answer is (almost) ALL (7-bit ASCII). If the inclusion rules is "...allowed under some/any/none conditions..." Just by looking at one of several possible inclusion rules for allowed text in the "domain text" part in RFC 5322 at the top of page 17 we find: dtext = %d33-90 / ; Printable US-ASCII %d94-126 / ; characters not including obs-dtext ; "[", "]", or "\" the only three missing chars in this description are used in domain-literal [], to form a quoted-pair \, and the white space character (%d32). With that the whole range 32-126 (decimal) is used. A similar requirement appear as "qtext" and "ctext". Many control characters are also allowed/used. One list of such control chars appears in page 31 section 4.1 of RFC 5322 as obs-NO-WS-CTL. obs-NO-WS-CTL = %d1-8 / ; US-ASCII control %d11 / ; characters that do not %d12 / ; include the carriage %d14-31 / ; return, line feed, and %d127 ; white space characters All this control characters are allowed as stated at the start of section 3.5: .... MAY be used, the use of US-ASCII control characters (values 1 through 8, 11, 12, and 14 through 31) is discouraged .... And such an inclusion rule is therefore "just too wide". Or, in other sense, the expected rule is "too simplistic". Share Share a link to this answer Copy linkCC BY-SA 3.0 Improve this answer Follow Follow this answer to receive notifications edited Oct 7, 2021 at 13:39 CommunityBot 111 silver badge answered Jun 21, 2015 at 4:56 user2350426user2350426 Add a comment | This answer is useful -1 Save this answer. Show activity on this post. As can be found in this Wikipedia link > The local-part of the email address may use any of these ASCII characters: > > * uppercase and lowercase Latin letters A to Z and a to z; > > * digits 0 to 9; > > * special characters !#$%&'*+-/=?^_`{|}~; > > * dot ., provided that it is not the first or last character unless quoted, > and provided also that it does not appear consecutively unless quoted (e.g. > John..Doe@example.com is not allowed but "John..Doe"@example.com is > allowed); > > * space and "(),:;<>@[\] characters are allowed with restrictions (they are > only allowed inside a quoted string, as described in the paragraph below, > and in addition, a backslash or double-quote must be preceded by a > backslash); > > * comments are allowed with parentheses at either end of the local-part; e.g. > john.smith(comment)@example.com and (comment)john.smith@example.com are > both equivalent to john.smith@example.com. > > In addition to the above ASCII characters, international characters above > U+007F, encoded as UTF-8, are permitted by RFC 6531, though mail systems may > restrict which characters to use when assigning local-parts. > > A quoted string may exist as a dot separated entity within the local-part, or > it may exist when the outermost quotes are the outermost characters of the > local-part (e.g., abc."defghi".xyz@example.com or "abcdefghixyz"@example.com > are allowed. Conversely, abc"defghi"xyz@example.com is not; neither is > abc\"def\"ghi@example.com). Quoted strings and characters however, are not > commonly used. RFC 5321 also warns that "a host that expects to receive mail > SHOULD avoid defining mailboxes where the Local-part requires (or uses) the > Quoted-string form". > > The local-part postmaster is treated specially—it is case-insensitive, and > should be forwarded to the domain email administrator. Technically all other > local-parts are case-sensitive, therefore jsmith@example.com and > JSmith@example.com specify different mailboxes; however, many organizations > treat uppercase and lowercase letters as equivalent. > > Despite the wide range of special characters which are technically valid; > organisations, mail services, mail servers and mail clients in practice often > do not accept all of them. For example, Windows Live Hotmail only allows > creation of email addresses using alphanumerics, dot (.), underscore (_) and > hyphen (-). Common advice is to avoid using some special characters to avoid > the risk of rejected emails. Share Share a link to this answer Copy linkCC BY-SA 3.0 Improve this answer Follow Follow this answer to receive notifications edited Oct 7, 2021 at 10:55 CommunityBot 111 silver badge answered Mar 21, 2014 at 12:06 Yash PatelYash Patel 5444 bronze badges 0 Add a comment | This answer is useful -2 Save this answer. Show activity on this post. In my PHP I use this check <?php if (preg_match( '/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', "tim'qqq@gmail.com" )){ echo "legit email"; } else { echo "NOT legit email"; } ?> try it yourself http://phpfiddle.org/main/code/9av6-d10r Share Share a link to this answer Copy linkCC BY-SA 3.0 Improve this answer Follow Follow this answer to receive notifications answered Jul 23, 2015 at 2:00 Yevgeniy AfanasyevYevgeniy Afanasyev 40k2828 gold badges183183 silver badges201201 bronze badges Add a comment | This answer is useful -2 Save this answer. Show activity on this post. For simplicity's sake, I sanitize the submission by removing all text within double quotes and those associated surrounding double quotes before validation, putting the kibosh on email address submissions based on what is disallowed. Just because someone can have the John.."The*$hizzle*Bizzle"..Doe@whatever.com address doesn't mean I have to allow it in my system. We are living in the future where it maybe takes less time to get a free email address than to do a good job wiping your butt. And it isn't as if the email criteria are not plastered right next to the input saying what is and isn't allowed. I also sanitize what is specifically not allowed by various RFCs after the quoted material is removed. The list of specifically disallowed characters and patterns seems to be a much shorter list to test for. Disallowed: local part starts with a period ( .account@host.com ) local part ends with a period ( account.@host.com ) two or more periods in series ( lots..of...dots@host.com ) &’`*|/ ( some&thing`bad@host.com ) more than one @ ( which@one@host.com ) :% ( mo:characters%mo:problems@host.com ) In the example given: John.."The*$hizzle*Bizzle"..Doe@whatever.com --> John..Doe@whatever.com John..Doe@whatever.com --> John.Doe@whatever.com Sending a confirm email message to the leftover result upon an attempt to add or change the email address is a good way to see if your code can handle the email address submitted. If the email passes validation after as many rounds of sanitization as needed, then fire off that confirmation. If a request comes back from the confirmation link, then the new email can be moved from the holding||temporary||purgatory status or storage to become a real, bonafide first-class stored email. A notification of email address change failure or success can be sent to the old email address if you want to be considerate. Unconfirmed account setups might fall out of the system as failed attempts entirely after a reasonable amount of time. I don't allow stinkhole emails on my system, maybe that is just throwing away money. But, 99.9% of the time people just do the right thing and have an email that doesn't push conformity limits to the brink utilizing edge case compatibility scenarios. Be careful of regex DDoS, this is a place where you can get into trouble. And this is related to the third thing I do, I put a limit on how long I am willing to process any one email. If it needs to slow down my machine to get validated-- it isn't getting past the my incoming data API endpoint logic. Edit: This answer kept on getting dinged for being "bad", and maybe it deserved it. Maybe it is still bad, maybe not. Share Share a link to this answer Copy linkCC BY-SA 3.0 Improve this answer Follow Follow this answer to receive notifications edited Feb 26, 2018 at 18:31 answered Jan 24, 2016 at 6:21 BradChesney79BradChesney79 64877 silver badges1616 bronze badges 4 * 2 I thing this answer is downvoted because this is an opinion, and it actually does not answer the question. Besides, users who get their email address silently sanitized will never get emails from you. You'd better inform them that their email address is not accepted. – vcarel Commented Jun 7, 2018 at 16:18 * 2 I suspect the downvotes are because there are too many ideas here. The disallowed list, while these are useful unit tests, should be prefaced with what is allowed. The programming approach seems relatively fine, but, would probably fit better after you list the specs you're working with, etc.. Sections and mild copy-editing would help. Just my 2cents. – HoldOffHunger Commented Sep 10, 2018 at 20:13 * @vcarel - Oh, absolutely. Front-end user side validation would inform them what rules (available from the tooltip) they were breaking. You are right-- it is an overall opinion. However, the question above is from someone that is asking X for a Y question for sure. This is guidance and it works... not only does it work, it works well. I don't let bullshit email addresses in my systems where I make the decisions. – BradChesney79 Commented Sep 11, 2018 at 13:25 * @HoldOffHunger I can see that the overall idea is not as coherently expressed as it could be, I may revise on another day where I have more time to better express that. Thanks for the insight. – BradChesney79 Commented Sep 11, 2018 at 13:27 Add a comment | This answer is useful -3 Save this answer. Show activity on this post. I created this regex according to RFC guidelines: ^[\\w\\.\\!_\\%#\\$\\&\\'=\\?\\*\\+\\-\\/\\^\\`\\{\\|\\}\\~]+@(?:\\w+\\.(?:\\w+\\-?)*)+$ Share Share a link to this answer Copy linkCC BY-SA 3.0 Improve this answer Follow Follow this answer to receive notifications edited May 19, 2017 at 20:26 answered Apr 19, 2017 at 21:02 MauMau 1533 bronze badges 1 * 1 This version improves the regex by checking the length of domain/subdomains. Enjoy! ^[\\w\\.\\!_\\%#\\$\\&\\'=\\?\*\\+\\-\\/\\^\`\\{\\|\\}\\~]+@(?:[\\w](?:[\\w\\-]{0,61}[\\w])?(?:\\.[\\w](?:[\\w\\-]{0,61}[\\w])?)*)$ – Mau Commented May 19, 2017 at 20:31 Add a comment | This answer is useful -4 Save this answer. Show activity on this post. Gmail will only allow + sign as special character and in some cases (.) but any other special characters are not allowed at Gmail. RFC's says that you can use special characters but you should avoid sending mail to Gmail with special characters. Share Share a link to this answer Copy linkCC BY-SA 3.0 Improve this answer Follow Follow this answer to receive notifications answered Sep 17, 2014 at 18:22 MohammedMohammed 1 Add a comment | Highly active question. Earn 10 reputation (not counting the association bonus) in order to answer this question. The reputation requirement helps protect this question from spam and non-answer activity. NOT THE ANSWER YOU'RE LOOKING FOR? BROWSE OTHER QUESTIONS TAGGED * FORMS * EMAIL * EMAIL-VALIDATION * EMAIL-ADDRESS OR ASK YOUR OWN QUESTION. * Featured on Meta * Upcoming sign-up experiments related to tags * The 2024 Developer Survey Is Live * The return of Staging Ground to Stack Overflow * Policy: Generative AI (e.g., ChatGPT) is banned Report this ad LINKED 77 Can there be an apostrophe in an email address? 0 MailAddress with single-quote 1 Why Laravel email validation accepting emojis? is it a larvel bug/issue? 0 Validate Email In CodeIgniter 3 4189 How can I validate an email address using a regular expression? 425 How to validate an e-mail address in Swift? 94 HTML5 Email input pattern attribute 75 Ruby Email validation with regex 89 Sql script to find invalid email addresses 67 Extract email sub-strings from large document See more linked questions RELATED 1232 What is the maximum length of a valid email address? 70 Are email addresses allowed to contain non-alphanumeric characters? 1 why are special character not alloed in email address 1 Valid email address format 0 What are the valid characters in the domain part of e-mail address? 10 What is the RFC 822 format for the email addresses? 5 Validate email address against invalid characters 1 Looking for a character that is allowed in Filenames but not allowed in email addresses... Any clue? 1 Email Address special characters confusion 3 Are unquoted consecutive (like) special characters allowed in an email address? HOT NETWORK QUESTIONS * Can we study scientifically the set of facts and behaviors if we have no scientific explanation for the source, origin or underlying mechanism of it? * What might cause an inner tube to "behave" flat in a tire? * Could alien species with blood based on different elements eat the same food? * Why is "Colourless green ideas sleep furiously" considered meaningless? * Can Pool Water Taken Directly from the Ocean Count for Mikveh בדיעבד? * What aspects define how present the garlic taste in an aglio e olio pasta becomes? * Would you be able to look directly at the Sun if it were a red giant? * Simulation of a battery with lifting up and role of salt bridge * One-liner double zugzwang * Does anyone know what Psatlees is more than it has something to do with silk? * Meaning of 電話も出ない * Ideal test/p-value calculation for difference in means with small sample size and right skewed data? * Usage and origin of the terms dictionary and atom in compressed sensing * Are state and Federal Grand Jury proceedings, testimony and deliberations secret in perpetuity? * Bound states between neutrinos using Schrödinger's equation? * Does every proof need an axiom saying it works? * tnih neddih eht kcehc * Recommendations Modifying/increasing a bicycles Max Weight limits * Is it possible for Mathematica to output the name of a matrix as opposed to its matrix form? * Why don't they put more spare gyroscopes in expensive space telescopes? * What was the title and author of this children's book of mazes? * What happens if you don't appear for jury duty for legitimate reasons in the state of California? * Approximating an Ellipse with Circular Arcs. * How much time is needed to judge an Earth-like planet to be safe? Question feed SUBSCRIBE TO RSS Question feed To subscribe to this RSS feed, copy and paste this URL into your RSS reader. STACK OVERFLOW * Questions * Help PRODUCTS * Teams * Advertising * Collectives * Talent COMPANY * About * Press * Work Here * Legal * Privacy Policy * Terms of Service * Contact Us * Cookie Settings * Cookie Policy STACK EXCHANGE NETWORK * Technology * Culture & recreation * Life & arts * Science * Professional * Business * API * Data * Blog * Facebook * Twitter * LinkedIn * Instagram Site design / logo © 2024 Stack Exchange Inc; user contributions licensed under CC BY-SA. rev 2024.6.20.11233 WE CARE ABOUT YOUR PRIVACY We and our 4 partners store and/or access information on a device, such as unique IDs in cookies to process personal data. You may accept or manage your choices by clicking below, including your right to object where legitimate interest is used, or at any time in the privacy policy page. These choices will be signaled to our partners and will not affect browsing data. Cookie Policy. WE AND OUR PARTNERS PERFORM THE FOLLOWING BASED ON YOUR SETTINGS: Use precise geolocation data. Actively scan device characteristics for identification. Understand audiences through statistics or combinations of data from different sources. Store and/or access information on a device. Develop and improve services. Create profiles to personalise content. Measure content performance. Use limited data to select content. Measure advertising performance. Use limited data to select advertising. Create profiles for personalised advertising. Use profiles to select personalised advertising. Use profiles to select personalised content. List of Partners (vendors) Accept all cookies Necessary cookies only Customize Settings