Webmail: HTML headers
Asked Answered
R

3

6

HTML e-mails are a complex beast. Deciding what to send (as the sender) and what to display (as the recipient) is tricky and potentially dangerous.

On the recipient side of things, we have webmail and we have regular e-mail clients. For my purposes, I consider 'webmail' anything that displays the HTML e-mail as part of something that in itself is HTML, and regular e-mail clients anything that displays the HTML e-mail in a different context (e.g. OS- and program-specific GUI).

What should webmail do with HTML headers (<head>, <title>, <meta>, ...) in an e-mail?
Is there a spec somewhere, be that as an actual standard or de-facto-standard?

My motivation for asking is that we use HTML Purifier to sanitise our HTML and if its Core.CollectErrors feature reports changes, they're reported. This 'reported' is both necessary... and frustrating. We strip out some of the reported errors as insignificant for our purposes, but HTML headers mark a massive hurdle:

Someone could potentially use <link> in their e-mail, which we would strip out. (HTML Purifier is intended for HTML fragments, not full documents)

The desire to use things like <link> in HTML e-mails certainly seems to exist, and there are plenty of e-mail clients that send <meta>-tags in an HTML header (e.g. Outlook), but how are things handled in the wild? Is it safe to strip them out silently (which for our purposes denotes a 'non-breaking change') and lay proverbial blame on the sending party if it does break? Is that reasonable? Has someone ever decided this in the one or other way? My google-fu is weak. :(

Ruinous answered 11/4, 2011 at 15:9 Comment(2)
IMHO, sending a link to a full fledged webpage is always the best answer. For other things, like email templates for reps in and out of Salesforce, I think we keep <head>, <meta> and <link>. Salesforce has it's own santizer which can be a bit of a challenge...Help
@esnyder: Thanks for your assessment. It's certainly another option; we consciously chose not to pursue it, but if all else fails, it might well be worth getting back to that. So thanks! :DRuinous
C
1

I seriously doubt there is a spec anywhere which specifies how HTML emails should be embedded into webmail clients. It's mostly a question of achieving parity with existing webmail providers which provide the ability to view HTML email. I suspect stylesheets are a notable exception, but I also suspect most HTML mailers that support that heavy styling are fairly constrained in what they can and cannot do, given how webmail things may handle them. I'd suggest doing some experiments, and consulting the source code of open-source webmail systems like SquirrelMail.

If you are worried about information loss, one thing that many clients allow you to do is download the original HTML, for offline viewing. Of course, it tends to be pretty atrocious, so I don't know why anyone would do that.

Commissary answered 8/6, 2011 at 16:33 Comment(2)
We do allow the download of the original source code. It's mostly a question of what is <s>the standard or</s> the de-facto standard for <head> in e-mails in webmail. SquirrelMail may be a good start in trying to figure that out - so thank you for that! :)Ruinous
Beyond SquirrelMail, you could also look at RoundCube, Horde and a few others. It will be time consuming, but I think the defacto standard you want to find is basically the consensus of existing webmail clients.Carlow
A
1

You should look at:

http://htmlemailboilerplate.com/

You will find a boilerplate code for HTML emails. There is also a good practice slideshow.

Alexine answered 15/6, 2011 at 7:22 Comment(2)
Initially I was going to say 'but that's the wrong side of the problem to look at'... then I realised that's actually really interesting; it indirectly (and sometimes directly) shows what other large webmailers accept. Thank you! This suggests HTML headers (but for <style>, but we already have that exception, so that comes as no surprise) should be silently dropped. Would you agree with that assessment?Ruinous
From what I understood, you are right. Except maybe for <title>. For example you can use the content in <title> if the mail title is empty.Alexine
C
0

My approach to HTML email is to to write the sort of basic HTML we were doing in the 1990's - table layouts, minimal inline CSS (for colours only) and thats pretty much it. I don't know how modern clients deal with CSS positioning but people are still using Outlook 2003 which I believe is based on the hateful rendering engine that runs IE6 - so it pays to go for lowest common denominator.

I've never seen anything that looked like a standard for it, i've seen some email clients (GMail) strip out various things - including CSS, and others just ignore certain things (Outlook & background images).

Rationally, I can't think of what use any meta information would be in an email anyway - its hard enough to get people to read your mail anyway, I suspect even less will view the source! I've always included a title tag in case anything wants to use it as a subject - but even thats a stab in the dark.

Whenever i've looked at how mails are requested server side - admittedly a while ago, but I never noticed that anything was cached. You open the mail, the requests are made again. I'm sure things have moved on since I last checked, but personally - i'd still be inclined keep HTML email as simple and stripped back as possible.

Cinemascope answered 13/6, 2011 at 1:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.