电子邮件地址中允许哪些字符? [英] What characters are allowed in an email address?

查看:1105
本文介绍了电子邮件地址中允许哪些字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是要求完整的电子邮件验证。

I'm not asking about full email validation.

我只想知道在 user-name 服务器电子邮件地址的部分。这可能是过于简单的,也许电子邮件地址可以采取其他形式,但我不在乎。我只是问这个简单的形式: user-name @ server (例如wild.wezyr@best-server-ever.com),并允许两部分的字符。 / p>

I just want to know what are allowed characters in user-name and server parts of email address. 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 (e.g. wild.wezyr@best-server-ever.com) and allowed characters in both parts.

推荐答案

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

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

RFC 822 还包括电子邮件地址,但主要涉及其结构:

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

 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:


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

The local-part of the email address may use any of these ASCII characters:


  • 大写和小写拉丁字母 A Z a z ;

  • 数字 0 9 ;

  • 特殊字符!#$%&'* + - / =?^ _`{|}〜;

  • dot ,前提是它不是第一个或最后一个字符,除非引用,并且还提供它不会连续出现,除非引用(例如 John..Doe @ example.com 不允许,但John..Doe@ example.com 被允许);

  • 空格和(),:;<> @ [\] 字符允许有限制(只允许在引用的字符串内部,如下面的段落所述,此外,反斜杠或双引号必须在之前带有反斜杠);

  • 允许任何一个括号中的注释的地方部分;例如 john.smith(comment)@ example.com (comment)john.smith@example.com 都是等效的到 john.smith@example.com

  • uppercase and lowercase Latin letters A to Z and a to z;
  • digits 0 to 9;
  • 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 (e.g. John..Doe@example.com is not allowed but "John..Doe"@example.com is allowed);
  • 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; e.g. john.smith(comment)@example.com and (comment)john.smith@example.com are both equivalent to john.smith@example.com.

除了ASCII字符,截至2012年,您可以使用国际以上字符 U + 007F ,编码为UTF-8

In addition to ASCII characters, as of 2012 you can use international characters above U+007F, encoded as UTF-8.

要进行验证,请参阅使用正则表达式验证电子邮件地址

部分已定义如下


互联网标准(请求评论)要求组件主机名标签可能只包含ASCII字母 a 通过 z (在一个不区分大小写的方式),数字 0 通过 9 和连字符( - )。 RFC 952 中的主机名的原始规范强制标签无法以数字开头或带有连字符,不能以连字符结尾。但是,随后的规范( RFC 1123 )允许主机名标签以数字开头。不允许使用其他符号,标点符号或空格。

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 (-). 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. However, a subsequent specification (RFC 1123) permitted hostname labels to start with digits. No other symbols, punctuation characters, or blank spaces are permitted.

这篇关于电子邮件地址中允许哪些字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆