Leading underscores in an email address?

独自空忆成欢 提交于 2019-12-10 02:06:43

问题


What RFC would I refer to in order to find out if a leading underscore in the local part of an email address is acceptable?

Example: _johndoe@hotmail.com

Of course, this question can also apply to any leading special character.

I found this line in Wikipedia, but couldn't find any reference within the RFC itself. Did I miss something here?

Local part The local-part of the email address may use any of these ASCII characters RFC 5322 Section 3.2.3:


回答1:


Quoting RFC5322.

Section 3.4.1 says:

An addr-spec is a specific Internet identifier that contains a
locally interpreted string followed by the at-sign character ("@",
ASCII value 64) followed by an Internet domain.  The locally
interpreted string is either a quoted-string or a dot-atom.

Going back to 3.2.3 you get:

atext       =   ALPHA / DIGIT /    ; Printable US-ASCII
                   "!" / "#" /        ;  characters not including
                   "$" / "%" /        ;  specials.  Used for atoms.
                   "&" / "'" /
                   "*" / "+" /
                   "-" / "/" /
                   "=" / "?" /
                   "^" / "_" /
                   "`" / "{" /
                   "|" / "}" /
                   "~"

atom           =   [CFWS] 1*atext [CFWS]

dot-atom-text  =   1*atext *("." 1*atext)

dot-atom       =   [CFWS] dot-atom-text [CFWS]

[CFWS] means comment or whitespace.

So the first part of an email address can be a dot-atom, which in turn begins with an atext, which can be an underscore.

Yes, an email address can begin with an underscore.




回答2:


Section 3.4.1 of that RFC defines how addresses are specified and references things defined in section 3.2.3. There's nothing that prohibits a leading "_".



来源:https://stackoverflow.com/questions/9200881/leading-underscores-in-an-email-address

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!