php 如何在 Gmail 中显示 <iframe> 标签
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16976966/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to display <iframe> tag to gmail
提问by user2247326
I use codeigniter to send email... After activating the user account it sends another email to insert tag but when the user receives the message, no tag appeared but when I tried using other elements like or it renders the style but how come doesn't?
我使用 codeigniter 发送电子邮件......激活用户帐户后,它会发送另一封电子邮件以插入标签,但是当用户收到消息时,没有标签出现,但是当我尝试使用其他元素时,或者它呈现样式,但为什么没有吨?
$message = 'Congratulations! Use the script below to add your widget.<br>';
$message .= "<iframe frameborder=\"0\" src=\"<?=base_url() ?>business/widget/{$id}\" height=\"320px;\" width=\"480px\" style=\"border: 1px solid #ccc;\"></iframe>";
$this->email->message($message);
if($this->email->send())
{
other code....
}
回答by Jared
Gmail and many other email clients are very strict about what HTML you can use in your HTML emails.
Gmail 和许多其他电子邮件客户端对可以在 HTML 电子邮件中使用的 HTML 非常严格。
<iframe>
is strictly off limits, because it could expose the user to a website which they were not expecting, and the website at the other end could record info about the user (such as their IP address). Images are blocked for similar reasons.
<iframe>
是严格禁止的,因为它可能会将用户暴露在他们意想不到的网站上,而另一端的网站可能会记录有关用户的信息(例如他们的 IP 地址)。图像因类似原因被屏蔽。
If I were you, I'd stick to using super basic HTML and CSS. Focus on getting the message to the user and hope their client makes the message look pretty. Always offer a link to view the full message elsewhere.
如果我是你,我会坚持使用超级基本的 HTML 和 CSS。专注于将消息传达给用户,并希望他们的客户使消息看起来很漂亮。始终提供链接以在别处查看完整消息。
回答by eggy
<iframe>
s cannot be used in most email clients – whether in an application or as a website. They are either stripped for one of several reasons:
<iframe>
s 不能在大多数电子邮件客户端中使用——无论是在应用程序中还是作为网站。它们要么由于以下几个原因之一被剥离:
- The mail/web client could have trouble rendering it, so it is excluded.
- An
<iframe>
could be used for phishing/malicious attacks, putting malicious code in what was otherwise vetted and safe (the browser/client can't see or scan what gets loaded into an iframe, it just loads it into the DOM).
- 邮件/Web 客户端可能无法呈现它,因此将其排除在外。
- An
<iframe>
可用于网络钓鱼/恶意攻击,将恶意代码放入经过和安全的内容中(浏览器/客户端无法看到或扫描加载到 iframe 中的内容,它只是将其加载到 DOM 中)。
An alternative, (what YouTube do), is instead of embedding something in an iframe (in their case, a video), they have an <a>
wrapped around an <img>
or thumbnail, which gives the impression that you are playing a video. All it does when you click on it, is it take you to that video's URL.
另一种选择(YouTube 所做的)不是在 iframe 中嵌入某些内容(在他们的情况下,是视频),而是有一个<a>
环绕的<img>
或 缩略图,给人一种您正在播放视频的印象。当您单击它时,它所做的一切就是将您带到该视频的 URL。
If you were trying to put extensive code into the email, you could manually write it in. This however has other effects, as some other tags are limited/styling can be a big hassle for emails. AFAIK some HTML5 elements are also stripped from emails.
如果您试图将大量代码放入电子邮件中,您可以手动将其写入。然而,这还有其他影响,因为其他一些标签是有限的/样式对电子邮件来说可能是一个大麻烦。AFAIK 一些 HTML5 元素也从电子邮件中删除。
As Orangepillsaid, Campaign Monitor have done the legwork and provided a chart showing where iframes can be used. They also suggest to stay away from iframes.
正如Orangepill所说,Campaign Monitor 已经完成了大量工作,并提供了一个图表,显示了可以在何处使用 iframe。他们还建议远离 iframe。
A solution not mentioned would be to have an image, with a link at the bottom that says View this message in a webpagewhich will take the user to a page with the <iframe>
working.
一个没有提到的解决方案是有一个图像,底部有一个链接,上面写着在网页中查看此消息,它将把用户带到一个<iframe>
工作页面。