把IdSMTP傳送郵件的內容改用HTML格式發現原本的HTMP標籤會截斷或是斷行,經過測試如果999各字元長度都不給予CRLF就會產生這樣的問題。收到的郵件格式會異常,查了一下發現RFC 5322 Internet Message Format就有寫明限制了:
2.1.1. Line Length Limits
There are two limits that this specification places on the number of
characters in a line. Each line of characters MUST be no more than
998 characters, and SHOULD be no more than 78 characters, excluding
the CRLF.
The 998 character limit is due to limitations in many implementations
that send, receive, or store IMF messages which simply cannot handle
more than 998 characters on a line. Receiving implementations would
do well to handle an arbitrarily large number of characters in a line
for robustness sake. However, there are so many implementations that
(in compliance with the transport requirements of [RFC5321]) do not
accept messages containing more than 1000 characters including the CR
and LF per line, it is important for implementations not to create
such messages.
The more conservative 78 character recommendation is to accommodate
the many implementations of user interfaces that display these
messages which may truncate, or disastrously wrap, the display of
more than 78 characters per line, in spite of the fact that such
implementations are non-conformant to the intent of this
specification (and that of [RFC5321] if they actually cause
information to be lost). Again, even though this limitation is put
on messages, it is incumbent upon implementations that display
messages to handle an arbitrarily large number of characters in a
line (certainly at least up to the 998 character limit) for the sake
of robustness.
文件建議每行不應該超過78各字,比較強的用詞是每行一定不可以超過998各字(中文可能是算2各字元,這個我沒有測試),平時還是要去研究一下各項協定的限制,不然盲測有點太花時間。所以保險作法就是每行78字元個就加上CRLF。