While working on the recordkeeping feature upgrade on our CMS, I noticed something odd. We’re adding functionality to auto-notify members of an RK category whenever a new post has been added. The message will include the text, title, poster’s name, and links to view the post and unsubscribe.
Should be pretty cool, but trying to ‘pretty up’ html emails is not cool. It seems like each email client/provider has their own way of displaying email. Some accept the <style> tag, some need inline styles. Some seem to just throw away all your styles and crap out whatever they want (looking at you, Outlook).
But Gmail’s webmail view has the oddest feature I’ve found so far. My simple email was rendering perfectly just about everywhere, except in Gmail on a full sized screen. It was always one line- the ‘view/edit this post’ link- and it almost never rendered the same way twice. There would be spaces between letters that weren’t in the source. Text that should be center aligned was flush left. Complete anarchy.
I checked the source view on a different client (couldn’t figure out how to get Gmail to show the source of just the message), and noticed that the email was being spit out by my program in one huge single line string. It’s generated by a PHP script, and I’d split it into multiple lines when creating it (to preserve my, and future editors, sanity), but didn’t explicitly add any \n newline calls.
On a whim, I gave it a shot. And it works! Maybe it’s a coincidence, but after I added a few \n newlines to the PHP script, the email renders just as I want, even in Gmail. Could be a fluke, but if someone else has a similar problem, it’s worth a shot.