Joe Scharf
posted this on February 12, 2010 13:39
If you are sending plain text emails, you may have noticed that, in some cases, your email is converted to HTML. This typically happens when you have one or more filters enabled that require a HTML version of the message you are sending.
Why does this happen?
The following filters convert plain text emails to HTML so the proper HTML tags can be inserted into the email:
How can I control the resulting conversion (see update below)
You can now disable plain-text to HTML conversion globally or just for click tracking.
Why can't you just automatically add <br /> tags to newlines upon conversion?
Due to the way plain text emails are sent (RFC 5822, Revised 2008) mailers are required to wrap lines at 998 characters, and recommends wrapping at 78 characters (excluding CR/LF). As a result, long sentences can often be broken up into multiple lines. Adding <br /> tags to each newline, would therefore create formatting problems.
For more information
We use the open-source library MKDoc-Text-Structured to perform the plain-text to HTML conversion. More information about this library and how it works can be found on the MKDoc-Text-Structured documentation page.
Comments
There is a nasty problem with the way you handle HTML conversion. When you follow RFC 5822 and add a wrap just before 998 characters, it appears you do so before you perform the HTML conversion. The added line break can often have a space at the beginning of the new line which causes your conversion function to add the PRE tag. As a result long paragraphs can often end up looking really horrible in most clients such as Apple Mail, Gmail, and Outlook. Here is a sample test we performed:
http://skitch.com/tony.spencer/d9mn7/inbox-2067-messages-1-unread
When sent from Gmail the identical body looks much nicer:
http://skitch.com/tony.spencer/d9mdf/inbox-2067-messages-1-unread
Also Gmail uses <br> tags for the HTML conversion of user added line breaks which looks much nicer when we have a single carriage return in an email (which will not result in any visible line break in your HTML converted emails)
Solution:
* Use <br> tags for line breaks instead of <p> tags
* Add compulsory line breaks after you've converted emails to HTML
Why are the <p> tags a bad idea?
Here is what an email converted to HTML and sent by SendGrid looks like (using <p> tags only on double CR's):
http://skitch.com/tony.spencer/d9m8h/inbox-2071-messages-1-unread
and the exact same body when sent from Gmail:
http://skitch.com/tony.spencer/d9men/inbox-2072-messages-1-unread
We've had to disable the HTML conversion in our account due to the awful formatting demonstrated above. As a result we can't tap into open rate statistics.
Sorry. Should have mentioned this in previous comments. The only issue with using <p> tags is that they have more vertical spacing than <br>. It isn't as big of a deal as the other issues of not converting single carriage returns, and adding the compulsory line break before converting to HTML.
Will be following up with a support request, but this is causing us issues as well - I also don't see the reasoning that <br>'s aren't added before applying RFC 5822 conversion?
Yes, we do line wrap emails before they are converted to HTML. Unfortunately this can cause some formatting issues when converting to HTML later. I've talked with our team and this is not something we plan to change. To fix this I would recommend either wrapping your lines before sending to us by using quoted-printable or base64 encoding, or you can send your mail as multipart/alternative with a text and HTML section already formatted on your end.
"...or you can send your mail as multipart/alternative with a text and HTML section already formatted on your end."
but we'd lose the ability to track Opened email which is my main motivation to fix your HTML problem
Just to confirm, my understanding is that plain text emails are NOT converted to HTML when:
AND
Is my understanding correct? I'm bit confused because it says ALL plain text emails are converted to HTML here :
http://sendgrid.com/documentation/display/settings/GlobalSettings