ZF說他們是有效的,因爲在技術上他們是。
根據RFC 2822 - Internet郵件格式,地址是addr-spec
格式(段3.4.1定義的
addr-spec = local-part "@" domain
local-part = dot-atom/quoted-string/obs-local-part
在什麼dot-atom
由展望:
3.2.4. Atom
Several productions in structured header field bodies are simply
strings of certain basic characters. Such productions are called
atoms.
Some of the structured header field bodies also allow the period
character (".", ASCII value 46) within runs of atext. An additional
"dot-atom" token is defined for those purposes.
atext = ALPHA/DIGIT/; Any character except controls,
"!"/"#"/ ; SP, and specials.
"$"/"%"/ ; Used for atoms
"&"/"'"/
"*"/"+"/
"-"/"/"/
"="/"?"/
"^"/"_"/
"`"/"{"/
"|"/"}"/
"~"
atom = [CFWS] 1*atext [CFWS]
dot-atom = [CFWS] dot-atom-text [CFWS]
dot-atom-text = 1*atext *("." 1*atext)
Both atom and dot-atom are interpreted as a single unit, comprised of
the string of characters that make it up. Semantically, the optional
comments and FWS surrounding the rest of the characters are not part
of the atom; the atom is only the run of atext characters in an atom,
or the atext and "." characters in a dot-atom.
正如你所看到的。 ,諸如*
,#
,!
,?
等字符是有效字符。
如果您想要考慮這些無效,您可以在EmailAddress::isValid()
返回true後檢查是否存在您認爲不允許在電子郵件地址中使用的特殊字符。