tags:

views:

6081

answers:

4

What is the maximum length of a valid email id

+8  A: 

320

And the segments look like this

{64}@{255}

64 + 1 + 255 = 320

You should also read this if you are validating emails

http://haacked.com/archive/2007/08/21/i-knew-how-to-validate-an-email-address-until-i.aspx

Bob
However according to this spec (for student loan data) http://www.nchelp.org/elibrary/ESC/CommonRecord-CommonLineDocumentation/CRC-Ver_1-3-0-PDF.pdf on page 20: "The e-mail length changed to reflect current ANSIstandards. The E-mail address is a maximum length of128 characters." Hmm.
Nathan
Can you reference what RFC you got this from?
Nathan
Here's a lovely article dispelling various myths about email including "max len == 320". The limit is actually 254.
Carl
Where is the lovely article?
Bob
He may mean this: http://www.dominicsayers.com/isemail
Dominic Sayers
+1  A: 

64 for the local part (the account/name) and 255 for the domain. I think the @ sign will be counted extra so that sums to 320.

But caution: this is only the length of the real address. An address may contain a display name. Such an address looks like first last <local@domain> and will often extend 320.

Arne Burmeister
But you will be sending the email over SMTP, so the address has to fit into the forward-path field, which has a maximum length of 256 characters.Also note that it will have angle brackets round it in this field so that actual address (including the @) can be no more than 254 characters.
Dominic Sayers
More here: http://www.dominicsayers.com/isemail
Dominic Sayers
A: 

You may want to consult: RFC 821.

I'm not sure if this RFC has been superseded by another RFC. According to my math it makes the longest email address 129 characters.

user    -  64 characters
domain  -  64 characters
at-sign -   1 character
------------------------
total   - 129 characters
Tim Stewart
Here's an interesting article: http://www.eph.co.uk/resources/email-address-length-faq/
Tim Stewart
RFC 821 was suerseded by RFC 2821 which was then superseded by RFC 5321. This was back before either of us had a goatee.See http://www.dominicsayers.com/isemail
Dominic Sayers
+33  A: 

The original version of RFC 3696 did indeed say 320 was the maximum length, but John Klensin subsequently accepted this was WRONG.

The maximum length is specified in RFC 5321: "The maximum total length of a reverse-path or forward-path is 256 characters"

RFC 3696 was corrected here

I note for the record that John Klensin may actually be wrong in his correction: 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, so the Mailbox must be no more than 254 characters to keep the path under 256.

I've now collated test cases from Cal Henderson, Dave Child, Phil Haack, Doug Lovell and RFC 3696. 158 test addresses in all.

I ran all these tests against all the validators I could find. The comparison is here: http://www.dominicsayers.com/isemail

I'll try to keep this page up-to-date as people enhance their validators. Thanks to Cal, Dave and Phil for their help and co-operation in compiling these tests and constructive criticism of my own validator.

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

Dominic Sayers
To sum up: the maximum length of an email address is **254** characters, as stated in http://www.dominicsayers.com/isemail/
Álvaro G. Vicario