mikel/mail — pull request #402 by pplr (2012-05-24 17:25:13+00:00)
Title: Some fields generate lines longer than 998 chars

RFC2822 says :
> Each line of characters MUST be no more than 998 characters, and SHOULD be no more than 78 characters, excluding the CRLF.

InReplyTo, Keyword, References or ResentMessageId fields are not folded at all. It's particularly annoying for the References field. Here is a common example of a mail that will be rejected by some mail servers with an error like "500 Line too long".

>> m = Mail.new do
?> from "foo@example.com"
>> to "bar@example.com"
>> message_id "1234@example.mail"
>> references " "
>> end
=> #, , , >>
>> puts m.encoded
Date: Thu, 24 May 2012 19:11:23 +0200
From: foo@example.com
To: bar@example.com
message-id: 1234@example.mail
References:
Mime-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit