Email 如何根据RFC 5322折叠具有长电子邮件地址的电子邮件标题?

Email 如何根据RFC 5322折叠具有长电子邮件地址的电子邮件标题?,email,header,rfc5322,Email,Header,Rfc5322,假设电子邮件具有以下标题字段: To: =?utf-8?q?Foo_Bar?= <1234567890123456789012345678901234567890123456789012345678901234@abcdefghiabcdefghiabcdefghiabcdefghiabcdefghiabcdefghiabcdefghi.com> 在正确的情况下,可以在域文本中插入折叠空格,以下内容应有效: To: =?utf-8?q?Foo_Bar?= <12345678

假设电子邮件具有以下标题字段:

To: =?utf-8?q?Foo_Bar?= <1234567890123456789012345678901234567890123456789012345678901234@abcdefghiabcdefghiabcdefghiabcdefghiabcdefghiabcdefghiabcdefghi.com>
在正确的情况下,可以在域文本中插入折叠空格,以下内容应有效:

To: =?utf-8?q?Foo_Bar?=
 <1234567890123456789012345678901234567890123456789012345678901234@abcdefgh
 iabcdefghiabcdefghiabcdefghiabcdefghiabcdefghiabcdefghi.com>
To:=?utf-8?q?Foo\u Bar=
但是,最新版本的postfix和exim拒绝了这一点:

501:  <1234567890123456789012345678901234567890123456789012345678901234@abcdefgh: '>' missing at end of address

<代码> 501:不允许在域中间(即您所做的)跨越域边界突破域,仅在域之前/之后。

RFC5322说你不应该打断
@
,但这并不意味着你可能不会

angle-addr      =   [CFWS] "<" addr-spec ">" [CFWS] /
                    obs-angle-addr

addr-spec       =   local-part "@" domain

local-part      =   dot-atom / quoted-string / obs-local-part

domain          =   dot-atom / domain-literal / obs-domain

domain-literal  =   [CFWS] "[" *([FWS] dtext) [FWS] "]" [CFWS]

dtext           =   %d33-90 /          ; Printable US-ASCII
                    %d94-126 /         ;  characters not including
                    obs-dtext          ;  "[", "]", or "\"

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]

specials        =   "(" / ")" /        ; Special characters that do
                    "<" / ">" /        ;  not appear in atext
                    "[" / "]" /
                    ":" / ";" /
                    "@" / "\" /
                    "," / "." /
                    DQUOTE
任何符合RFC的地址解析器都需要处理这个问题


(这里是自我提升,但由的地址解析器处理;-)

我感觉可能是SMTP客户端出错了
域文本
表单需要“[”和“]”。它仅用于IP地址,例如
hello@[127.0.0.1]
。由于
obs域
,我的语法阅读只允许在“.”周围折叠空格。RFC5322规定“不得生成这些语法形式”。
angle-addr      =   [CFWS] "<" addr-spec ">" [CFWS] /
                    obs-angle-addr

addr-spec       =   local-part "@" domain

local-part      =   dot-atom / quoted-string / obs-local-part

domain          =   dot-atom / domain-literal / obs-domain

domain-literal  =   [CFWS] "[" *([FWS] dtext) [FWS] "]" [CFWS]

dtext           =   %d33-90 /          ; Printable US-ASCII
                    %d94-126 /         ;  characters not including
                    obs-dtext          ;  "[", "]", or "\"

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]

specials        =   "(" / ")" /        ; Special characters that do
                    "<" / ">" /        ;  not appear in atext
                    "[" / "]" /
                    ":" / ";" /
                    "@" / "\" /
                    "," / "." /
                    DQUOTE
[CFWS]
"<"
[CFWS] 
"1234567890123456789012345678901234567890123456789012345678901234"
[CFWS]
"@"
[CFWS] 
"abcdefghiabcdefghiabcdefghiabcdefghiabcdefghiabcdefghiabcdefghi"
"."
"com"
[CFWS]
">"
To: =?utf-8?q?Foo_Bar?=
 <
 1234567890123456789012345678901234567890123456789012345678901234
 @
 abcdefghiabcdefghiabcdefghiabcdefghiabcdefghiabcdefghiabcdefghi.com
 >