Mad*_*ter 15 email smtp sendmail
我遇到了 NAGIOS 系统向流行的电子邮件到短信服务发送电子邮件的问题。电子邮件到短信服务接收带有文本的电子邮件Subject:,并将它们发送到To:字段中编码的手机号码。到现在为止还挺好。可悲的是,sendmail的(和前后缀)似乎将无偿CRLF到(不一定长)Subject:线,而这造成我的短信,以在CRLF被截断,当且仅当该Subject:行包含一个或多个冒号过去没来由CRLF。
我相信这些消息是正确创建的,但可以肯定的是,这里是我为自己创建了一个完全 noddy 测试消息,Subject:一行很长:
echo "foo" | mail -s "1234567 101234567 201234567 301234567 401234567 501234567 601234567 701234567 801234567 90123456789" reaper@teaparty.net
Run Code Online (Sandbox Code Playgroud)
注意这一Subject:行没有多余的冒号;我在这里所做的只是显示在电线上插入了一个额外的 CRLF。这是结果sudo ngrep -x port 25:
44 61 74 65 3a 20 46 72 69 2c 20 33 31 20 4d 61 Date: Fri, 31 Ma
79 20 32 30 31 33 20 31 30 3a 34 33 3a 35 35 20 y 2013 10:43:55
2b 30 31 30 30 0d 0a 54 6f 3a 20 72 65 61 70 65 +0100..To: reape
72 40 74 65 61 70 61 72 74 79 2e 6e 65 74 0d 0a r@teaparty.net..
53 75 62 6a 65 63 74 3a 20 31 32 33 34 35 36 37 Subject: 1234567
20 31 30 31 32 33 34 35 36 37 20 32 30 31 32 33 101234567 20123
34 35 36 37 20 33 30 31 32 33 34 35 36 37 20 34 4567 301234567 4
30 31 32 33 34 35 36 37 20 35 30 31 32 33 34 35 01234567 5012345
36 37 0d 0a 20 36 30 31 32 33 34 35 36 37 20 37 67.. 601234567 7
30 31 32 33 34 35 36 37 20 38 30 31 32 33 34 35 01234567 8012345
36 37 20 39 30 31 32 33 34 35 36 37 38 39 0d 0a 67 90123456789..
55 73 65 72 2d 41 67 65 6e 74 3a 20 48 65 69 72 User-Agent: Heir
6c 6f 6f 6d 20 6d 61 69 6c 78 20 31 32 2e 34 20 loom mailx 12.4
37 2f 32 39 2f 30 38 0d 0a 4d 49 4d 45 2d 56 65 7/29/08..MIME-Ve
72 73 69 6f 6e 3a 20 31 2e 30 0d 0a 43 6f 6e 74 rsion: 1.0..Cont
65 6e 74 2d 54 79 70 65 3a 20 74 65 78 74 2f 70 ent-Type: text/p
6c 61 69 6e 3b 20 63 68 61 72 73 65 74 3d 75 73 lain; charset=us
大约一半(以粗体+斜体标记),在原始标题中的501234567和之间,您可以看到插入了一个 CRLF(在左侧的十六进制转储中,在右侧的纯文本中)。601234567Subject:0x0d 0x0a..
接收 MTA 似乎很乐意对此进行后处理,当我查看接收端磁盘上存储的邮件时,我只看到主题:行中的 LF (0x0a),并且该行被正确解析并在其整体由,例如,alpine。尽管如此,CRLF 仍然存在,在我和(优秀的)电子邮件到短信支持人员之间,我们已经确定这些是问题的原因。
所以我的问题是:MTA 在线路上插入一个免费的 CRLF 是否合法?
如果是,而且我可以证明这一点,那么这是电子邮件到短信公司的问题,因为他们无法容忍。如果不是,或者是但我无法证明,那么它就成了我的问题,因此带有参考资料的答案将是最有用的。
编辑:我现在可以清楚地知道有问题的电子邮件到短信服务是kapow。一旦向他们解释了这个问题,他们就明白了,与我一起开发和测试修复程序,并部署了修复程序。我的带有冒号的长主题行现在可以正确地转发到 SMSes 中。我通常不会吹嘘个别公司,尤其是在 SF 上,但我认为值得注意的是 kapow 做了正确的事。(免责声明:我与 kapow 没有任何关系,除非作为付费客户对他们处理问题的方式感到满意。)
Nic*_*ckW 16
好吧,如果我了解 RFC 822,它们在某些情况下是合法的,我认为这是 24x80 分辨率的小屏幕时代的产物。
这些部分似乎很清楚主题可以折叠,折叠是一个 CRLF 加上 LWSP(线性空白)字符..它们可能已经被 supeseded,Wietse(在后缀列表中)如果你愿意的话,他的 RFC 会彻底了解一个明确的答案。
3.1.1. LONG HEADER FIELDS
Each header field can be viewed as a single, logical line of
ASCII characters, comprising a field-name and a field-body.
For convenience, the field-body portion of this conceptual
entity can be split into a multiple-line representation; this
is called "folding". The general rule is that wherever there
may be linear-white-space (NOT simply LWSP-chars), a CRLF
immediately followed by AT LEAST one LWSP-char may instead be
inserted. Thus, the single line
To: "Joe & J. Harvey" <ddd @Org>, JJV @ BBN
can be represented as:
To: "Joe & J. Harvey" <ddd @ Org>,
JJV@BBN
and
To: "Joe & J. Harvey"
<ddd@ Org>, JJV
@BBN
and
To: "Joe &
J. Harvey" <ddd @ Org>, JJV @ BBN
The process of moving from this folded multiple-line
representation of a header field to its single line represen-
tation is called "unfolding". Unfolding is accomplished by
regarding CRLF immediately followed by a LWSP-char as
equivalent to the LWSP-char.
Note: While the standard permits folding wherever linear-
white-space is permitted, it is recommended that struc-
tured fields, such as those containing addresses, limit
folding to higher-level syntactic breaks. For address
fields, it is recommended that such folding occur
between addresses, after the separating comma.
3.1.2. STRUCTURE OF HEADER FIELDS
Once a field has been unfolded, it may be viewed as being com-
posed of a field-name followed by a colon (":"), followed by a
field-body, and terminated by a carriage-return/line-feed.
The field-name must be composed of printable ASCII characters
(i.e., characters that have values between 33. and 126.,
decimal, except colon). The field-body may be composed of any
ASCII characters, except CR or LF. (While CR and/or LF may be
present in the actual text, they are removed by the action of
unfolding the field.)
Certain field-bodies of headers may be interpreted according
to an internal syntax that some systems may wish to parse.
These fields are called "structured fields". Examples
include fields containing dates and addresses. Other fields,
such as "Subject" and "Comments", are regarded simply as
strings of text.
Note: Any field which has a field-body that is defined as
other than simply <text> is to be treated as a struc-
tured field.
Field-names, unstructured field bodies and structured
field bodies each are scanned by their own, independent
"lexical" analyzers.
3.1.3. UNSTRUCTURED FIELD BODIES
For some fields, such as "Subject" and "Comments", no struc-
turing is assumed, and they are treated simply as <text>s, as
in the message body. Rules of folding apply to these fields,
so that such field bodies which occupy several lines must
therefore have the second and successive lines indented by at
least one LWSP-char.
Run Code Online (Sandbox Code Playgroud)
提问者编辑:我希望 NickW 能原谅我添加了一个注释,说明 RFC822 已被 RFC2822 废弃,但新的 RFC 在其第 2.2.3 节中说了几乎相同的事情,并明确确认这种折叠应该在进行任何进一步处理之前将其删除:
每个标题字段在逻辑上都是一行字符,包括字段名称、冒号和字段主体。然而,为了方便并处理每行 998/78 个字符的限制,标题字段的字段主体部分可以拆分为多行表示;这称为“折叠”。一般规则是,只要该标准允许折叠空白(不仅仅是 WSP 字符),CRLF 就可以插入任何 WSP 之前。例如,头字段:
Run Code Online (Sandbox Code Playgroud)Subject: This is a test可以表示为:
Run Code Online (Sandbox Code Playgroud)Subject: This is a test注意:虽然结构化字段主体的定义方式使得折叠可以发生在许多词法标记之间(甚至在一些词法标记内),但折叠应该仅限于
将 CRLF 放置在更高级别的句法中断处。例如,如果字段主体定义为逗号分隔值,则建议在分隔结构项的逗号之后优先折叠字段可以折叠的其他位置,即使在其他地方允许折叠也是如此。从标题字段的这种折叠的多行表示移动到其单行表示的过程称为“展开”。展开是通过简单地删除任何紧跟 WSP 的 CRLF 来完成的。每个标题字段都应以其展开的形式进行处理,以进行进一步的句法和语义评估。
这并不是要贬低这样一个事实,即 NickW 准确无误地向我指出了我需要知道的几乎所有内容,只是为了帮助这个答案与将来可能偶然发现它的任何人保持相关性。
| 归档时间: |
|
| 查看次数: |
4664 次 |
| 最近记录: |