[squeak-dev] Sending html emails with MailMessage; line length issues
Tony Garnock-Jones
tonyg at leastfixedpoint.com
Wed Jun 22 08:44:26 UTC 2022
On 6/22/22 02:18, tim Rowledge wrote:
> The non-broken mail
> a) doesn't break within a tag
> b) has 4k long lines instead of 998 char lines.
MIME has a line length limit. From
https://datatracker.ietf.org/doc/html/rfc2822#section-2.1.1:
There are two limits that this standard 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.
It looks like maybe WAHtmlCanvasBuilder is producing a single long line
of HTML (commendable!) but them that MIMEDocument isn't honouring the
length limit.
Yep:
(MailMessage new body: (MIMEDocument contentType: 'text/html'
content: (String new: 5000))) text lines collect: [:line | line size]
--> #(37 23 0 5000)
Setting a content-transfer-encoding header fixes the line-length
problem. I expect you'll not have deliverability problems with base64
encoding, but you could try that or quoted-printable:
(MailMessage new body: ((MIMEDocument contentType: 'text/html'
content: (String new: 5000)) setField: 'content-transfer-encoding'
toString: 'base64')) text lines collect: [:line | line size]
--> #(37 23 33 0 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72
72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72
72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72
72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72
72 72 72 44)
Cheers,
Tony
(Just an aside: you have two "Content-type" headers in the sample you
posted, and while email header names are expected to be processed
case-insensitively, I am superstitious about these things and would have
it with a capital "t", "Content-Type"... well, I'd go look at the spec
and do what it suggests in there...)
More information about the Squeak-dev
mailing list
|