What is the maximum length of a valid email address?

441,184

Solution 1

An email address must not exceed 254 characters.

This was accepted by the IETF following submitted erratum. A full diagnosis of any given address is available online. The original version of RFC 3696 described 320 as the maximum length, but John Klensin subsequently accepted an incorrect value, since a Path is defined as

Path = "<" [ A-d-l ":" ] Mailbox ">"

So the Mailbox element (i.e., the email address) has angle brackets around it to form a Path, which a maximum length of 254 characters to restrict the Path length to 256 characters or fewer.

The maximum length specified in RFC 5321 states:

The maximum total length of a reverse-path or forward-path is 256 characters.

RFC 3696 was corrected here.

People should be aware of the errata against RFC 3696 in particular. Three of the canonical examples are in fact invalid addresses.

I've collated a couple hundred test addresses, which you can find at http://www.dominicsayers.com/isemail

Solution 2

320

And the segments look like this

{64}@{255}

64 + 1 + 255 = 320

You should also read this if you are validating emails: I Knew How To Validate An Email Address Until I Read The RFC

Solution 3

user

The maximum total length of a user name is 64 characters.

domain

Maximum of 255 characters in the domain part (the one after the “@”)

However, there is a restriction in RFC 2821 reading:

The maximum total length of a reverse-path or forward-path is 256 characters, including the punctuation and element separators”. Since addresses that don’t fit in those fields are not normally useful, the upper limit on address lengths should normally be considered to be 256, but a path is defined as: Path = “<” [ A-d-l “:” ] Mailbox “>” The forward-path will contain at least a pair of angle brackets in addition to the Mailbox, which limits the email address to 254 characters.

Solution 4

To help the confused rookies like me, the answer to "What is the maximum length of a valid email address?" is 254 characters.

If your application uses an email, just set your field to accept 254 characters or less and you are good to go.

You can run a bunch of tests on an email to see if it is valid here. http://isemail.info/

The RFC, or Request for Comments is a type of publication from the Internet Engineering Task Force (IETF) that defines 254 characters as the limit. Located here - https://www.rfc-editor.org/rfc/rfc5321#section-4.5.3

Solution 5

According to the below article:

https://www.rfc-editor.org/rfc/rfc3696 (Page 6, Section 3)

It's mentioned that:

"There is a length limit on email addresses. That limit is a maximum of 64 characters (octets) in the "local part" (before the "@") and a maximum of 255 characters (octets) in the domain part (after the "@") for a total length of 320 characters. Systems that handle email should be prepared to process addresses which are that long, even though they are rarely encountered."

So, the maximum total length for an email address is 320 characters ("local part": 64 + "@": 1 + "domain part": 255 which sums to 320)

Share:
441,184
volatilevoid
Author by

volatilevoid

A software writer who wants to write _nothing_

Updated on July 15, 2022

Comments

  • volatilevoid
    volatilevoid almost 2 years

    What is the maximum length of a valid email address? Is it defined by any standard?

    • Toby Speight
      Toby Speight over 6 years
      What kind of email address? Internet, X.400, or other?
    • MGOwen
      MGOwen about 6 years
      Note that the length limit your app should impose for email addresses might not be the same as the theoretical maximum (which is longer than this whole comment). Other answers discuss that question, e.g.: stackoverflow.com/questions/1297272
  • Nathan
    Nathan about 15 years
    However according to this spec (for student loan data) nchelp.org/elibrary/ESC/CommonRecord-CommonLineDocumentation‌​/… on page 20: "The e-mail length changed to reflect current ANSI standards. The E-mail address is a maximum length of 128 characters." Hmm.
  • Nathan
    Nathan about 15 years
    Can you reference what RFC you got this from?
  • abcd
    abcd almost 15 years
    Here's a lovely article dispelling various myths about email including "max len == 320". The limit is actually 254.
  • Bob
    Bob almost 15 years
    Where is the lovely article?
  • Pacerier
    Pacerier almost 12 years
    What about the new RFC standard which allows Unicode in email addresses?
  • Dominic Sayers
    Dominic Sayers almost 12 years
    The new RFCs do not alter the fact that SMTP imposes this limit on the envelope. They have been designed for backward compatibility with existing MTA software.
  • Geoffrey
    Geoffrey about 11 years
    How many characters before the @ and how many after, or does it not matter?
  • Lodewijk
    Lodewijk over 10 years
    What if SMTP is superseded? Does this mean we are technically incapable of implementing the standard in RFC 3696? 254 practically, 320 future proof? Going with 254 now anyway :)
  • Dominic Sayers
    Dominic Sayers over 10 years
    @Lodewijk RFC 3696 isn't a standard, it just tries to help people interpret the underlying standards correctly. Unfortunately, in his attempt to clarify the situation, Klensin included some gross errors that were corrected in the Errata. But nobody reads the errata so RFC 3693 ends up being very unhelpful, ironically.
  • vp_arth
    vp_arth almost 9 years
    This answer correct. This emails valid, but absolutely unusable, because 2821 restrict MAIL/RCPT commands to 256 with <> brackets...
  • vp_arth
    vp_arth almost 9 years
    Cool, ancient rfc of 1982... There is rfc5321 for SMTP
  • doABarrelRoll721
    doABarrelRoll721 over 8 years
    Good luck printing 254 characters in one line in a PDF-document.
  • Andre D
    Andre D about 8 years
    I believe with internationalized e-mail addresses, it would be more correct to define the limit as 254 octets, not characters. But I'm not sure. RFC 6531 extends the RFC 5321 reverse- and forward-path to allow UTF-8 characters, but RFC 5321 specifically says the limit is "256 octets", including separators (a deliberate change from RFC 2821 which said "characters"). I believe the 256-octet limit (minus 2 for 254) is not superseded, and the effective character limit is reduced for addresses with multi-byte UTF-8 characters.
  • Aaron Esau
    Aaron Esau over 7 years
    Does that include emails in the format user+inbox@domain?
  • Aaron Esau
    Aaron Esau over 7 years
    Does that include emails that are formatted like user+inbox@domain?
  • Dominic Sayers
    Dominic Sayers over 7 years
    @Arin: yes it does
  • JohnLBevan
    JohnLBevan almost 7 years
    Is anyone else confused as to why the limit for the domain (255) is larger than the limit for the full address (254)? Is there a justification (or at least, explanation) for that scenario?
  • Dominic Sayers
    Dominic Sayers almost 7 years
    @JohnLBevan because domains are used for other purposes besides emails and are defined by different RFCs. I'm sure Jon Postel wished he could make it more consistent but at the time most domains were very short and it would have been overkill to break the envelope addresses in to two or more packets simply to take account of the potential for very long domain names.
  • Binarus
    Binarus over 6 years
    I have stumbled across the same issue as @AndreD, and I agree with him. On the other hand, dominicsayers.com/isemail still says it is 254 characters. Does anybody know more? I believe it is octets and not characters, but that would mean that theoretically the maximum number of characters could be 63. I can't believe that the new RFC 6531 does not deal with that problem, so I am unsure.
  • Kamlesh
    Kamlesh almost 5 years
    could you please provide me regular expression in javascript to validate 320 characters email id? Thanks in advance.
  • Sperry
    Sperry over 4 years
    The "user+inbox" portion still needs to fit in 64 characters. Its still the localpart and the '+' does not add any magic to it.
  • Matthijs Kooijman
    Matthijs Kooijman over 4 years
    This part of the standard was amended in errata to include a total limit of 254 characters. See the accepted answer for details and links to the errata.
  • Matthijs Kooijman
    Matthijs Kooijman over 4 years
    This answer misses references. It probably comes from RFC3696, but this part of the standard was amended in errata to include a total limit of 254 characters. See the accepted answer for details and links to the errata.
  • Steven Eckhoff
    Steven Eckhoff about 4 years
    When I do find that one psycho who has 254 characters in their email should I care? Do I want this kind of person using my service?
  • NeoH4x0r
    NeoH4x0r over 3 years
    It is actually on Page 4, Section 3 (Restrictions on email addresses) tools.ietf.org/html/rfc3696#section-3
  • Brendan Quinn
    Brendan Quinn about 3 years
    @Geoffrey, the errata linked in the answer above answers your question: "a maximum of 64 characters (octets) in the "local part" (before the "@") and a maximum of 255 characters (octets) in the domain part (after the "@") for a total length of 320 characters. However, there is a restriction in RFC 2821 on the length of an address in MAIL and RCPT commands of 256 characters." So max 64 octets before the @, max 255 after the @, BUT with an overall limit of 254 octets, including the @.
  • HoldOffHunger
    HoldOffHunger almost 3 years
    Where are you reading "254 characters"? I see in the link you provided, "The maximum total length of a reverse-path or forward-path is 256." Ctrl+F on "254" finds nothing, also.
  • Michael Große
    Michael Große almost 3 years
    @HoldOffHunger There: rfc-editor.org/errata_search.php?rfc=3696&eid=1690 "However, there is a restriction in RFC 2821 on the length of an address in MAIL and RCPT commands of 254 characters. Since addresses that do not fit in those fields are not normally useful, the upper limit on address lengths should normally be considered to be 254."
  • HoldOffHunger
    HoldOffHunger almost 3 years
    @MichaelGroße Thanks! That info is actually listed in my answer (in fact, I list exactly #3696, among others), ended up answering after I couldn't get a response, but thanks for confirming my hunch about this answer.