HTML< base>电子邮件中的标记 [英] HTML <base> tag in email

查看:149
本文介绍了HTML< base>电子邮件中的标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有内容管理的解决方案(SDL Tridion,具体而言,但问题更一般),其中包含多个网站,其中包含不同语言的内容。它们都共享一些基于Razor的模板,这些模板用于在发布页面时呈现带有特定注入内容的HTML片段。

CRM也通过CMS进行管理,相同的模板用于创建电子邮件新闻稿。这些HTML电子邮件包含图像,这些图像发布到管理相关分发列表的任何网站。由于模板系统是通用的,CMS没有最终产品绝对URL的概念,因此这些图像都嵌入了相关地址。我们有能力将绝对URL作为元数据应用于CMS中的不同网站,并编写.Net扩展以将这些URL格式化为渲染的图像标签;但是,这会增加这项工作的开销。



我们可以通过使用< base href =...来解决这个问题。 /> 标记位于电子邮件标记的< head> 部分。这似乎至少在Outlook中起作用;然而,我一直无法找到关于哪些电子邮件客户端做的最新信息,也不支持这个标签。



然后问题:多么广泛支持在电子邮件客户端 - 特别是基于浏览器的 - 是< base> 标签?

解决方案

遗憾的是,它不适用于大多数基于网络的电子邮件客户端(Hotmail,Gmail),并且通常会增加大约30%的接收者。

为什么它不起作用:
大多数基于网络的客户端都会在您的电子邮件的主体标签内注入任何内容,并且删除其他所有内容,包括。因此,如果您发送:

 < html> 
< head>< base ...>< / head>
< body>< p class =youremail>电子邮件< / p>< / body>
< / html>

电子邮件客户端执行以下操作:

 < HTML> 
< head><电子邮件客户端>< / head>
< body>
<电子邮件客户端封套>
< email>
< p class =youremail>电子邮件< / p>
< / email>
<电子邮件客户端封套> ...
< / body>

所以你的基本标签将被剥离。即使不是,由于它不包含在电子邮件客户端的头部,它将被浏览器忽略。



不幸的是,图像上的绝对路径是走。我通过使用'预检处理器'来解决过去类似的问题。您可以使用它获取< base> href,并在返回完成的HTML之前将其设置为所有图像。


We have a content-managed solution (SDL Tridion, to be specific; however, the question is more general), which includes multiple sites with content of different languages. They all share a number of Razor-based templates, which are used to render HTML fragments with specific injected content when pages are published.

CRM is also managed through the CMS and the same templating is used for the creation of email newsletters. These HTML emails contain images, which are published out to whatever site manages the distribution list in question. Because the templating system is generic and the CMS has no concept of the absolute URLs of the final product, these images are all embedded with relative addresses. We have the capacity to apply an absolute URL as metadata to the different websites in the CMS and write .Net extensions to format these URLs into rendered image tags; however, this would add considerable overhead to this piece of work.

We can resolve this by using a <base href="..." /> tag in the <head> section of the email's markup. This seems to work in Outlook, at least; however, I have not been able to find much up-to-date information on what email clients do and do not support this tag.

The question, then: How widely supported among email clients - particularly browser-based ones - is the <base> tag?

解决方案

Unfortunately, it won't work for most web-based email clients (Hotmail, Gmail) and that typically adds up to about 30% of receivers.

Why it won't work: Most web-based clients inject whatever's inside the body tag of your email and strip out everything else, including the head. So, if you send:

<html>
<head><base ...></head>
<body><p class="youremail">Email</p></body>
</html>

The email client does this:

<html>
<head><Email client head></head>
<body>
  <email client wrapper>
  <email>
    <p class="youremail">Email</p>
  </email>
  <email client wrapper>...
</body>

So your base tag will be stripped. Even if it wasn't, since it's not include in the email client's head, it will be ignored by the browser.

Unfortunately, absolute paths on images is the way to go. I have got over similar problems in the past by using a 'preflight processor'. You could use that to get the <base> href and set it on all the images before returning the finished HTML.

这篇关于HTML&lt; base&gt;电子邮件中的标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆