简体   繁体   English

网络邮件:HTML标头

[英]Webmail: HTML headers

HTML e-mails are a complex beast. HTML电子邮件是一门复杂的动物。 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 (eg OS- and program-specific GUI). 就我的目的而言,我认为“ webmail”是指将HTML电子邮件显示为本身是HTML的一部分的内容,普通电子邮件客户端是指在不同上下文中显示HTML电子邮件的任何内容(例如OS和特定于程序的GUI)。

What should webmail do with HTML headers ( <head> , <title> , <meta> , ...) in an e-mail? Webmail应该如何处理电子邮件中的HTML标头( <head><title><meta> ,...)?
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. 我询问的动机是,我们使用HTML Purifier清理HTML,如果其Core.CollectErrors功能报告更改,则将其报告。 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: 我们删除了一些对于我们的目的而言微不足道的报告错误,但是HTML标头标志着一个巨大的障碍:

Someone could potentially use <link> in their e-mail, which we would strip out. 有人可能会在他们的电子邮件中使用<link> ,我们将对此予以删除。 (HTML Purifier is intended for HTML fragments , not full documents) (HTML Purifier适用于HTML 片段 ,而非完整文档)

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 (eg Outlook), but how are things handled in the wild? 在HTML电子邮件中使用诸如<link>类的东西的愿望似乎确实存在 ,并且有许多电子邮件客户端在HTML标头(例如Outlook)中发送<meta> -tag,但是如何处理野外? 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. 我的谷歌福很弱。 :( :(

I seriously doubt there is a spec anywhere which specifies how HTML emails should be embedded into webmail clients. 我非常怀疑在任何地方都有规范可以指定HTML电子邮件应如何嵌入到Webmail客户端中。 It's mostly a question of achieving parity with existing webmail providers which provide the ability to view HTML email. 这主要是要与提供查看HTML电子邮件功能的现有网络邮件提供商实现同等的问题。 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. 我怀疑样式表是一个明显的例外,但是我也怀疑大多数支持重型样式的HTML邮件在其可以做什么和不能做什么方面都受到了一定的限制,考虑到网络邮件的处理方式。 I'd suggest doing some experiments, and consulting the source code of open-source webmail systems like SquirrelMail. 我建议做一些实验,并咨询像SquirrelMail这样的开放源Webmail系统的源代码。

If you are worried about information loss, one thing that many clients allow you to do is download the original HTML, for offline viewing. 如果您担心信息丢失,许多客户端允许您做的一件事就是下载原始HTML,以供离线查看。 Of course, it tends to be pretty atrocious, so I don't know why anyone would do that. 当然,它往往非常残酷,所以我不知道为什么有人会这样做。

You should look at: 您应该看一下:

http://htmlemailboilerplate.com/ http://htmlemailboilerplate.com/

You will find a boilerplate code for HTML emails. 您将找到HTML电子邮件的样板代码。 There is also a good practice slideshow. 还有一个很好的幻灯片演示。

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. 我处理HTML电子邮件的方法是编写我们在1990年代所做的基本HTML-表格布局,最小的内联CSS(仅用于颜色),仅此而已。 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. 我不知道现代客户如何处理CSS定位,但是人们仍在使用Outlook 2003,我相信它基于运行IE6的可恶的渲染引擎-因此,它需要付出最低的公分母。

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). 我从未见过任何看起来像它的标准的东西,我曾见过一些电子邮件客户端(GMail)剥离了各种东西-包括CSS,而其他电子邮件客户端仅忽略了某些东西(Outlook和背景图片)。

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. 我敢肯定,自上次检查以来,情况已经发生了变化,但就我个人而言,我仍然倾向于保持HTML电子邮件尽可能简单并尽可能减少。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM