网络邮件:HTML 标头

发布于 2024-10-31 17:51:03 字数 1252 浏览 4 评论 0原文

HTML 电子邮件是一个复杂的庞然大物。决定发送什么(作为发送者)和显示什么(作为接收者)是很棘手的,而且有潜在的危险。

在收件人方面,我们有网络邮件,并且我们有常规电子邮件客户端。就我的目的而言,我认为“网络邮件”是任何将 HTML 电子邮件显示为本身就是 HTML 的一部分的东西,而常规电子邮件客户端是在不同上下文(例如操作系统和操作系统)中显示 HTML 电子邮件的任何东西。程序特定的 GUI)。

Webmail 应该如何处理 HTML 标头(</code>、<code><meta></code>、... )在电子邮件中?</strong><br> 是否有某个规范,作为实际标准或事实上的标准?

我提问的动机是我们使用 HTML Purifier 来净化我们的 HTML,如果它 Core.CollectErrors 功能报告更改,它们被报告。这种“报告”既是必要的……又令人沮丧。我们删除了一些报告的错误,因为这些错误对我们的目的来说无关紧要,但 HTML 标头标志着一个巨大的障碍:

有人可能在他们的电子邮件中使用 ,我们将删除这些错误(HTML Purifier 适用于 HTML 片段,而不是完整文档)

在 HTML 电子邮件中使用 等内容的愿望当然< a href="http://www.acyba.com/en/support/forum/2-bug-report/17852-stylesheet-not-available-in-email-head.html" rel="noreferrer">似乎存在,并且有很多电子邮件客户端在 HTML 标头中发送 标记(例如 Outlook),但是如何在野外处理这些事情呢?默默地将它们删除(对于我们的目的而言,这表示“非破坏性更改”)并在它确实破坏时将责任归咎于发送方是否安全?这合理吗?有人曾经以一种或另一种方式做出过这样的决定吗?我的谷歌功能很弱。 :(

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. :(

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

逆光飞翔i 2024-11-07 17:51:03

我严重怀疑是否有任何规范指定 HTML 电子邮件应如何嵌入到网络邮件客户端中。这主要是一个与现有网络邮件提供商实现平等的问题,这些提供商提供了查看 HTML 电子邮件的能力。我怀疑样式表是一个值得注意的例外,但我也怀疑大多数支持这种繁重样式的 HTML 邮件程序在它们能做什么和不能做什么方面受到相当的限制,考虑到 webmail 的处理方式。我建议做一些实验,并查阅开源网络邮件系统(如 SquirrelMail)的源代码。

如果您担心信息丢失,许多客户端允许您做的一件事就是下载原始 HTML,以供离线查看。当然,这往往是相当残暴的,所以我不知道为什么有人会这样做。

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.

清旖 2024-11-07 17:51:03

您应该查看:

http://htmlemailboilerplate.com/

您会找到 HTML 电子邮件的样板代码。还有一个很好的练习幻灯片。

You should look at:

http://htmlemailboilerplate.com/

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

指尖上得阳光 2024-11-07 17:51:03

我处理 HTML 电子邮件的方法是编写我们在 1990 年代所做的基本 HTML - 表格布局、最小内联 CSS(仅适用于颜色),仅此而已。我不知道现代客户如何处理 CSS 定位,但人们仍在使用 Outlook 2003,我相信它是基于运行 IE6 的令人讨厌的渲染引擎 - 所以追求最低公分母是值得的。

我从未见过任何看起来像它的标准的东西,我见过一些电子邮件客户端(GMail)删除了各种东西 - 包括 CSS,而其他客户端则忽略了某些东西(Outlook 和背景图像)。

从理性上讲,我无法想象电子邮件中的任何元信息有什么用处 - 无论如何,它都很难让人们阅读您的邮件,我怀疑更少的人会查看源代码!我总是包含一个标题标签,以防万一有什么东西想用它作为主题——但即便如此,这也是在黑暗中进行的。

每当我查看服务器端如何请求邮件时——诚然是不久前,但我从未注意到有任何内容被缓存。您打开邮件,再次发出请求。我确信自从我上次检查以来事情已经发生了变化,但就我个人而言 - 我仍然倾向于保持 HTML 电子邮件尽可能简单和精简。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文