AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 512229
Accepted
MadHatter
MadHatter
Asked: 2013-06-01 02:02:10 +0800 CST2013-06-01 02:02:10 +0800 CST 2013-06-01 02:02:10 +0800 CST

Subject: line 中的 Gratuitous CRLF - 为什么它在那里,它合法吗?

  • 772

我遇到了 NAGIOS 系统向流行的电子邮件到 SMS 服务发送电子邮件的问题。电子邮件到短信服务接收Subject:行中带有文本的电子邮件,并将它们发送到To:字段中编码的手机号码。到目前为止,一切都很好。可悲的是,sendmail(和它之前的 postfix)似乎在(必须很长的)行中插入了一个无偿的 CRLF Subject:,这导致我的 SMS 消息在 CRLF 处被截断,当且仅当该Subject:行包含一个或多个冒号超过无偿的CRLF。

我相信这些消息是正确创建的,但为了确定,这里是我为自己创建一个完全 noddy 测试消息,有一条长线Subject::

echo "foo" | mail -s "1234567 101234567 201234567 301234567 401234567 501234567 601234567 701234567 801234567 90123456789" [email protected]

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    [email protected]..
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 似乎很乐意对此进行后处理,当我在接收端查看磁盘上存储的邮件时,我在 Subject: 行中只看到一个 LF (0x0a),并且该行被正确解析并在其完整,例如,alpine。然而,CRLF 在线路上,在我和(优秀的)电子邮件到 SMS 支持人员之间,我们已经确定这些是问题的原因。

所以我的问题是:MTA 在网络上插入无偿 CRLF 是否合法?

如果是,而且我可以证明,那就是电子邮件到 SMS 机构的问题,因为他们不宽容。如果不是,或者是但我无法证明,那么它就成了我的问题,因此带参考的答案将是最有用的。

编辑:我现在可以清楚地知道,有问题的电子邮件到短信服务是kapow。一旦向他们解释了这个问题,他们就明白了,与我一起开发和测试修复,并部署了修复。我带有冒号的长主题行现在可以正确地转发到 SMS 中。我通常不会吹嘘个别公司,尤其是在 SF 上,但我认为值得一提的是,kapow 做了正确的事。(免责声明:我与 kapow 没有任何关系,只是作为付费客户对他们处理问题的方式感到满意。)

email
  • 2 2 个回答
  • 5310 Views

2 个回答

  • Voted
  1. Best Answer
    NickW
    2013-06-01T02:41:55+08:002013-06-01T02:41:55+08:00

    好吧,如果我理解 RFC 822,它们在某些情况下是合法的,我认为这是 24x80 分辨率的小屏幕时代的产物。

    这些部分似乎相当清楚主题可以折叠,折叠是一个 CRLF 加上 LWSP(线性空白)字符..它们可能已被取代,如果你愿意,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.
    

    发问者编辑:我希望 NickW 能原谅我添加一条注释,说明 RFC822 已被 RFC2822 淘汰,但新的 RFC 在其 2.2.3 节中说了几乎相同的事情,并明确确认这种折叠应该在进行任何进一步处理之前被删除:

    每个标题字段在逻辑上都是一行字符,包括字段名称、冒号和字段主体。然而,为了方便,并处理每行 998/78 字符的限制,标题字段的字段主体部分可以拆分为多行表示;这称为“折叠”。一般规则是,只要此标准允许折叠空格(不仅仅是 WSP 字符),就可以在任何 WSP 之前插入 CRLF。例如头字段:

           Subject: This is a test
    

    可以表示为:

           Subject: This
            is a test
    

    注意:虽然结构化字段体的定义方式使得折叠可以发生在许多词汇标记之间(甚至在某些词汇标记内),但折叠应该限于
    将 CRLF 放置在更高级别的句法中断处。例如,如果字段主体定义为逗号分隔值,建议折叠发生在逗号分隔结构化项之后,而不是字段可以折叠的其他位置,即使在其他地方允许。

    从标题字段的折叠多行表示移动到其单行表示的过程称为“展开”。展开是通过简单地删除紧跟在 WSP 之后的任何 CRLF 来完成的。每个头字段都应该以其展开的形式进行处理,以进行进一步的句法和语义评估。

    这并不是要贬低 NickW 准确无误地向我指出了我需要知道的几乎所有内容这一事实,只是为了帮助这个答案对未来可能偶然发现它的任何人保持相关性。

    • 16
  2. AnFi
    2013-06-01T04:08:29+08:002013-06-01T04:08:29+08:00

    Sendmail服务器(SendMail) 施加了 SMTP 行长度限制,但它要高得多(对于 smtp 邮件程序,990 字节或更多)。

    发送邮件 != 发送电子邮件

    据我了解,Nagios 默认使用 SendEmail客户端发送电子邮件。您使用 Nagios 的电子邮件客户端似乎对电子邮件标题/主题行的长度施加了如此“严格”的限制。

    commands.cfg检查并报告配置文件中配置的电子邮件客户端。
    (notify-host-by-email和notify-service-by-email设置)。

    • 2

相关问题

  • 如何绕过 ISP 的限制性电子邮件政策?

  • SharePoint 传入电子邮件出现“未知别名”错误

  • 电子邮件帐户的角色名称与人名

  • 如何在笔记本电脑上使用 Tobit David?[关闭]

  • 随行人员通过 VPN 连接到 Exchange 2007

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve