Search code examples
html-emailcss-reset

How to display an HTML email in a web email client?


Hi I am building a small web based email client. I am facing problems in displaying HTML mails. What are the best practices involved in displaying an HTML mail? Some things I found

  1. Css Reset
  2. Strip body tag in the mail

Solution

  • First of all, it's important to not allow all the CSS and HTML tags. I would look for the file and allow a defined set of HTML tags and CSS attributes.

    For example, if you reset the CSS, you can still send stuff like <iframe>, <form> and all other possible malicious tags.

    So I would start of thinking what kind of HTML tags would you like to support, and strip all other ones out of it. And then the same for the CSS.

    This is by no means easy. I mean you also would have to take in account things like people trying to break your interpreter...

    You could look into this Sitepoint Blogpost, it describes how people should code HTML-emails. So it might be a good idea to start there and see what's usually supported.