Apple Mail bug: chopping up long strings

For a client, I recently converted their build-by-hand electronic newsletter to one that’s automatically generated based on stories picked from the last few weeks. Handy, because the newsletter is now created much quicker, even though the editor has less control over the look and feel.

The first week the mailing was sent out, all was well, or rather, seemed to be well. Then, the second week, in the test newsletter which was sent out, the client noticed that, at seemingly random points inside the mailing, spaces had been added. Not too much of an issue, though annoying, if this happened inside a piece of text, but as this was an HTML mailing, rather annoying when this actually happened inside a piece of code.
This, of course, because it had the potential of breaking the HTML.

Before finalizing my work, I had of course extensively tested my new creation and found all to be well. The problem, as it turned out, was only replicable on Apple Mail. That’s no less than 10% of email clients, so serious stuff.
Totally baffled, after more testing, I initially gave up, after making very sure that the HTML used for the newsletter validated nicely and there really was nothing that I, or the system, was doing wrong.

Then, today, a week after the issue was discovered, I had a brainfart. Though the spaces appeared to be put in at random, there seemed to be some method to the madness. Which made me think of… string length.

And, indeed, it seems that Apple Mail can’t properly deal with HTML mail where the HTML is formed by long strings. I chopped up the original HTML, myself, putting in multiple line breaks and, voila, Apple Mail no longer coughed up any hairballs.

Related:  Little creatures