What is the maximum length of a valid email address? Is it defined by any standard?
相关问题
- Date with SimpleDateFormat in Java
- RegEx Max and Min length characters for a Text Box
- How to add sender name before sender address in py
- Android: Using Intent to send email - only offerin
- Verify if an email address exists or not
相关文章
- Angular Material Stepper causes mat-formfield to v
- Why doesn't Django enforce my unique_together
- How do I make a forward e-mail link?
- X/Html Validator in PHP
- Using CascadeMode.StopOnFirstFailure on a validato
- DDD Domain Model Complex Validation
- Debug HTML Email in Gmail App
- Sending email using php, gmail, and swiftmailer ca
According to the below article:
http://tools.ietf.org/html/rfc3696 (Page 6, Section 3)
It's mentioned that:
So, the maximum total length for an email address is 320 characters ("local part": 64 + "@": 1 + "domain part": 255 which sums to 320)
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
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
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:
RFC 3696 was corrected here.
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.
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://tools.ietf.org/html/rfc5321#section-4.5.3
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.However, there is a restriction in RFC 2821 reading: