How to validate html email templates?

R K Sharma picture R K Sharma · May 18, 2016 · Viewed 8.9k times · Source

I am using telerik reporting tool to generate reports in different formats, .pdf,.html, .doc, .txt etc. Some of our client's email server doesn't sport attachment in emails so I want to embed the .html report to my email body instead of attaching it as attachment so user can see report content directly and copy report content. But when I append .html report to the email body it doesn't render in proper format as it was. Is there any online tool or plugin which convert the normal html to email template friendly html? Or how can I validate that this page is going to render fine as email body or not if not then why not? which tag should I remove or replace etc.

I have tried this online tool but its not working, still got dirty html in email.

Answer

Ted Goas picture Ted Goas · May 25, 2016

There are a couple questions in here, which I will do my best to answer as someone who is comfortable coding emails.

Regarding HTML Email validation, there really isn't a good option.

Since most email clients don’t follow web standards and there are no email-specific standards in place, properly coded HTML emails will not pass HTML validating because, if coded properly, nearly all of the code within an HTML email is likely to be comprised of deprecated elements. source

You can use the W3C validator to catch unclosed tags and typos, but that's about it.

But it sounds like you're looking for a tool that converts webpage-friendly html into email-friendly html. Despite both using HTML and CSS, coding emails is quite different from coding the web. Unless the web-friendly HTML design is very basic (say, a series of paragraphs and images), chances are the webpage-friendly html would not bode well in email clients. (Sounds like you've already discovered this.)

Without knowing what these reports look like and what how they should display in email clients, I'm hesitant to give you specific suggestions. I don't know any tools that automatically make 'safe' email markup. If you're open to tweaking the email markup a little, here are a few guidelines:

  1. Keep the design simple.
  2. Use <table>s instead of semantic elements like <div> for layout.
  3. Become familiar with what CSS is and is not safe to use in an email.