有效电子邮件地址的最大长度是多少?

发布于 2024-07-10 07:29:14 字数 36 浏览 10 评论 0 原文

有效电子邮件地址的最大长度是多少? 它有任何标准定义吗?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

以酷 2024-07-17 07:29:14

电子邮件地址不得超过 254 个字符。

提交勘误后,IETF 接受了此内容。 可以在线获得任何给定地址的完整诊断。 RFC 3696 的原始版本将 320 描述为最大长度,但 John Klensin 随后接受了错误的值,因为 Path 被定义为

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

因此 Mailbox 元素(即电子邮件地址)周围有尖括号以形成 Path,这最大长度为 254 个字符,以将路径长度限制为 256 个字符或更少。

RFC 5321 中指定的最大长度规定:

反向路径或正向路径的最大总长度为 256 个字符。

RFC 3696 已在此处进行更正。

人们应该特别注意针对 RFC 3696 的勘误表。 三个规范示例实际上是无效地址。

我整理了数百个测试地址,您可以在 http://www.dominicsayers.com/isemail< /a>

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

晨曦慕雪 2024-07-17 07:29:14

320

这些分段看起来像这样

{64}@{255}

64 + 1 + 255 = 320

如果您要验证电子邮件,还应该阅读以下内容:在阅读 RFC 之前我知道如何验证电子邮件地址

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

迷爱 2024-07-17 07:29:14

RFC 2821 指定:

本地部分

用户名或其他本地部分的最大总长度为 64
字符。

域名

域名或号码的最大总长度为255
字符。

但是,还有进一步的限制阅读:

路径

反向路径或正向路径的最大总长度为 256
字符(包括标点符号和元素分隔符)。

正如 Dominic Sayers 在其验证并接受的RFC 3696 勘误表中所解释的那样< /a>:

RFC 2821 对转发路径设置了 256 个字符的限制。
但路径定义为

路径=“<”   [ Adl ":" ] 邮箱 ">" 
  

因此前向路径将至少包含一对尖括号
除了邮箱之外。 这限制了邮箱(即电子邮件
地址
)到254个字符。

RFC 2821 specifies:

local-part

The maximum total length of a user name or other local-part is 64
characters.

domain

The maximum total length of a domain name or number is 255
characters.

However, there is a further restriction reading:

path

The maximum total length of a reverse-path or forward-path is 256
characters (including the punctuation and element separators).

As Dominic Sayers explains in his verified and accepted erratum on RFC 3696:

RFC 2821 places a 256 character limit on the forward-path.
But a path is defined as

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

So the forward-path will contain at least a pair of angle brackets
in addition to the Mailbox. This limits the Mailbox (i.e. the email
address
) to 254 characters.

心意如水 2024-07-17 07:29:14

为了帮助像我这样困惑的菜鸟,回答“有效电子邮件地址的最大长度是多少?” 是254 个字符

如果您的应用程序使用电子邮件,只需将您的字段设置为接受 254 个或更少的字符即可。

您可以对电子邮件进行一系列测试,看看它在这里是否有效。 http://isemail.info/

RFC(或请求评论)是互联网工程任务组的一种出版物(IETF) 将 254 个字符定义为限制。 位于此处 - https://www.rfc-editor.org/rfc/ rfc5321#section-4.5.3

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

缺⑴份安定 2024-07-17 07:29:14

根据以下文章:

https://www.rfc-editor.org/rfc/rfc3696(第6页,第3节

提到:

“有长度限制
电子邮件地址。 该限制最多为 64 个字符(八位字节)
在“本地部分”(“@”之前),最多 255 个字符
(八位位组)在域部分(“@”之后),总长度为 320
人物。 处理电子邮件的系统应该准备好处理
这么长的地址,尽管很少见
遇到过。”

因此,电子邮件地址的最大总长度为 320 个字符
(“本地部分”:64 +“@”:1 +“域部分”:255,总和为 320)

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)

ゝ杯具 2024-07-17 07:29:14

其他答案有点把水搅浑了。
简单答案:我们控制的电子邮件总字符数为 254
256 代表整个电子邮件地址,其中包含隐含的“<” 开头和“>” 在最后。 因此,还剩下254个供我们使用。

The other answers muddy the water a bit.
Simple answer: 254 total chars in our control for email
256 are for the ENTIRE email address, which includes implied "<" at the beginning, and ">" at the end. Therefore, 254 are left over for our use.

掩于岁月 2024-07-17 07:29:14

TLDR 答案

给定一个电子邮件地址,例如...

[email protected]

长度限制如下:

  • 整个电子邮件地址(又名:“路径”):即,[电子邮件受保护] -- 最多 256 个字符。
  • 本地部分:即,me - 最多 64 个字符。
  • 域名:即 example.com - 最多 254 个字符。

来源——TLDR;

RFC 标准在不断发展,但如果您想在一行中获取 2009 年 IETF 源代码:

...地址长度的上限通常应视为 256。(来源:RFC3696。)

来源 — 历史

SMTP 最初定义了 RFC821,1982 年 8 月发布,即 官方互联网标准(大多数 RFC 只是提案)。 引用它...

...反向路径,指定邮件来自谁。

...转发路径,指定邮件的收件人。

RFC2821,于 2001 年 4 月发布,是已过时的标准,定义了我们当前的本地最大值- 部分、域和路径。 2008 年 10 月发布的新标准草案 RFC5321 保留了相同的限制。 在这两个日期之间,RFC3696 于 2004 年 2 月发布。它错误地引用了最大值电子邮件地址限制为 320 个字符,但本文档仅供“参考”,并指出:“本备忘录为互联网社区提供信息。它不指定任何类型的互联网标准。” 所以,我们可以忽略它。

引用 RFC2821,RFC5321 中确认的现代公认标准......

4.5.3.1.1。 本地部分

用户名或其他本地部分的最大总长度为 64
字符。

4.5.3.1.2。 域名

域名或号码的最大总长度为 255 个字符。

4.5.3.1.3。 路径

反向路径或正向路径的最大总长度为 256
字符(包括标点符号和元素分隔符)。

您会注意到,我指示的域最大值为 254,而 RFC 指示的域最大值为 255。这是一个简单的算术问题。 255 个字符的域加上“@”符号就是一个 256 个字符的路径,这是最大路径长度。 不过,空名称或空白名称是无效的,因此域实际上最多有 254 个。

TLDR Answer

Given an email address like...

[email protected]

The length limits are as follows:

  • Entire Email Address (aka: "The Path"): i.e., [email protected] -- 256 characters maximum.
  • Local-Part: i.e., me -- 64 character maximum.
  • Domain: i.e., example.com -- 254 characters maximum.

Source — TLDR;

The RFC standards are constantly evolving, but if you want a 2009 IETF source in a single line:

...the upper limit on address lengths should normally be considered to be 256. (Source: RFC3696.)

Source — The History

SMTP originally defined what a path was in RFC821, published August 1982, which is an official Internet Standard (most RFC's are only proposals). To quote it...

...a reverse-path, specifies who the mail is from.

...a forward-path, which specifies who the mail is to.

RFC2821, published in April 2001, is the Obsoleted Standard that defined our present maximum values for local-parts, domains, and paths. A new Draft Standard, RFC5321, published in October 2008, keeps the same limits. In between these two dates, RFC3696 was published, on February 2004. It mistakenly cites the maximum email address limit as 320-characters, but this document is "Informational" only, and states: "This memo provides information for the Internet community. It does not specify an Internet standard of any kind." So, we can disregard it.

To quote RFC2821, the modern, accepted standard as confirmed in RFC5321...

4.5.3.1.1. Local-part

The maximum total length of a user name or other local-part is 64
characters.

4.5.3.1.2. Domain

The maximum total length of a domain name or number is 255 characters.

4.5.3.1.3. Path

The maximum total length of a reverse-path or forward-path is 256
characters (including the punctuation and element separators).

You'll notice that I indicate a domain maximum of 254 and the RFC indicates a domain maximum of 255. It's a matter of simple arithmetic. A 255-character domain, plus the "@" sign, is a 256-character path, which is the max path length. An empty or blank name is invalid, though, so the domain actually has a maximum of 254.

戏蝶舞 2024-07-17 07:29:14

可悲的是,所有其他答案都是错误的。 其中大多数引用 RFC 2821 或更新版本,其中甚至没有定义电子邮件地址。 它所做的就是定义路径。 电子邮件地址由 RFC 2822(或更新版本)定义,并且可以更长。 有效地址但不是有效路径的示例有:

(Firstname Lastname) user@domain
Firstname Lastname <user@domain>

这两个都是相同的邮箱,但写法不同。 因此,如果您的目标是将电子邮件地址存储在数据库中,则 254、256 或 320 个八位字节的限制可能太低,但实际上这很少会成为问题。

Sadly, all the other answers are wrong. Most of them cite RFC 2821 or newer, which does not even define e-mail addresses. What it does do is define paths. E-mail addresses are defined by RFC 2822 (or newer) and can be much longer. Examples of valid addresses that are not valid paths are:

(Firstname Lastname) user@domain
Firstname Lastname <user@domain>

Both of these are the same mailbox written differently. So if your goal is to store e-mail addresses in a database, a limit of 254, 256 or 320 octets might be too low, although in practise, this is rarely going to be a problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文