Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
526 views
in Technique[技术] by (71.8m points)

forms - 电子邮件地址允许使用哪些字符?(What characters are allowed in an email address?)

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.

(我只是想知道电子??邮件地址的user-nameserver部分中允许的字符是什么。)

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 (eg [email protected]) and allowed characters in both parts.

(我只询问这个简单的形式: user-name@server (例如[email protected])和两个部分允许的字符。)

  ask by WildWezyr translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

See RFC 5322: Internet Message Format and, to a lesser extent, RFC 5321: Simple Mail Transfer Protocol .

(请参阅RFC 5322:Internet邮件格式,以及在较小程度上的RFC 5321:简单邮件传输协议 。)

RFC 822 also covers email addresses, but it deals mostly with its structure:

(RFC 822也涵盖了电子邮件地址,但它主要涉及其结构:)

 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

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:

(电子邮件地址的本地部分可以使用以下任何ASCII字符:)

  • uppercase and lowercase Latin letters A to Z and a to z ;

    (大写和小写拉丁字母AZaz ;)

  • digits 0 to 9 ;

    (数字09 ;)

  • 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 (eg [email protected] is not allowed but "John..Doe"@example.com is allowed);

    (,除非引用,否则它不是第一个或最后一个字符,并且除非引用,否则它也不会连续出现(例如, [email protected]不允许,但是“ "John..Doe"@example.com [email protected]是允许);)

  • 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;

    (本地部分两端的括号允许注释;)

    eg john.smith(comment)@example.com and (comment)[email protected] are both equivalent to [email protected] .

    (如john.smith(comment)@example.com(comment)[email protected]都等同于[email protected] 。)

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 .

(除ASCII字符外, 截至2012年,您可以使用U+007F 以上的国际字符 ,编码为UTF-8,如RFC 6532规范中所述,并在Wikipedia上进行了解释。)

Note that as of 2019, these standards are still marked as Proposed, but are being rolled out slowly.

(请注意,截至2019年,这些标准仍然标记为建议,但正在缓慢推出。)

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 @: .

(此规范中的更改实际上将国际字符添加为有效的字母数字字符(atext),而不会影响允许和限制的特殊字符(如!#@: :)的规则。)

For validation, see Using a regular expression to validate an email address .

(有关验证,请参阅使用正则表达式验证电子邮件地址 。)

The domain part is defined as follows :

(domain部分定义如下 :)

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 ( - ).

(协议的Internet标准(Request for Comments)要求组件主机名标签可以仅包含ASCII字母az (以不区分大小写的方式),数字09以及连字符( - )。)

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.

(RFC 952中主机名的原始规范,强制标签不能以数字或连字符开头,并且不得以连字符结尾。)

However, a subsequent specification ( RFC 1123 ) permitted hostname labels to start with digits.

(但是,后续规范( RFC 1123 )允许主机名标签以数字开头。)

No other symbols, punctuation characters, or blank spaces are permitted.

(不允许使用其他符号,标点字符或空格。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...