[squeak-dev] Sending html emails with MailMessage; line length issues

tim Rowledge tim at rowledge.org
Wed Jun 22 00:18:15 UTC 2022


I'm trying to send email reports with html tables and having issues with *some* mail servers breaking the html in bad places.

Trying to google stuff about html mail mostly leads to gazillions of puff pieces about "Why Your Brand Needs Enhanced HTML Mail!" and so on. This leads to early onset brain-rot.

I'm using MailMessage and providing it with a body of a MIMEDocument contentType: 'text/html' content: abigstringofhtml . The html is being built by WAHtmlCanvasBuilder but I don't *think* that is the cause of my problems. I also use 
	message
 		setField: 'content-type' toString: 'text/html; charset=utf8';
		setField: 'mime-version' toString: '1.0'.

Some mail smtp servers seem to be happy; if I send myself an email via my rowledge.org server, no problem. If I use an smtp set up on a vanilla Ubuntu 20 machine the lines of the html content get split in bad places that result in very ugly tables. I haven't been able to find anything that suggests smtp settings related to this, nor anything that makes me suspect I have to add any other message fields or so on.

The broken mails look like this - 

To: XXXXXXXX
Date: Fri, 10 Jun 2022 16:48:19 -0700
Subject: Daily Report
Mime-version: 1.0
Content-type: text/html;charset=utf8
Content-type: text/html
Message-Id: XXXXXXXXX
X-DA-Pass: W0T0
X-CTCH-Spam: Unknown
X-CTCH-VOD: Unknown
X-CTCH-RefID: str=0001.0A742F2A.62A3D849.0002,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0
X-Origin-Country: CA
X-WHL: LR

<html><head><title>Report</title></head><body onload="onLoad()"><h3>Your report, requested at 2022-06-10T16:48:19.783908-07:00</h3><table class="table table-bordered table-hover table-condensed"><thead><tr><th>AggregateDataRecordDate</th><th>AggregateDataRecordStatusNormal</th></tr></thead><tfoot><tr><td></td><td></td></tr></tfoot><tbody><tr style="background-color: lightblue"><td>2022-02-14</td><td>340</td></tr><tr style="background-color: lightyellow"><td>2022-02-22</td><td>306</td></tr><tr style="background-color: lightblue"><td>2022-02-02</td><td>374</td></tr><tr style="background-color: lightyellow"><td>2022-01-23</td><td>136</td></tr><tr style="background-color: lightblue"><td>2022-02-06</td><td>340</td></tr><tr style="background-color: lightyellow"><td>2022-01-01</td><td>170</td></tr><tr style="background-color: lightblue"><td>2022-02-28</td><td>306</td></tr><tr style="background-color: lightyellow"><td>2022-02-23</td><td>306</td></tr><tr style="background-color: lightblue"><t
 d>2022-01-24</td><td>136</td></tr>

Note the break at the end where a <td> tag is split by a CR and a space.

The non-broken mail
a) doesn't break within a tag
b) has 4k long lines instead of 998 char lines.

Pointers to explanations, advice, solutions, all most welcome!

tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
All computers run at the same speed...with the power off.




More information about the Squeak-dev mailing list