如何强制电子邮件程序显示使用 php 以 html 电子邮件发送的图像?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2527555/
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 can I force email programs to show images send in html email using php?
提问by zeckdude
I am sending an html email with php and it includes an image. Some email programs, such as gMail have a 'display images' button. The user has to click on that in order for the images in the email to show up.
我正在发送一封带有 php 的 html 电子邮件,其中包含一个图像。一些电子邮件程序,例如 gMail,有一个“显示图像”按钮。用户必须单击它才能显示电子邮件中的图像。
Is there any way I can force email programs to show images that are sent within html emails generated by php?
有什么方法可以强制电子邮件程序显示在 php 生成的 html 电子邮件中发送的图像?
回答by Quentin
As a rule of thumb, email clients are configured to display attached images by default (e.g. those with a cid: URI scheme) and not load remote images (which can include tracking information).
根据经验,电子邮件客户端被配置为默认显示附加图像(例如那些具有 cid: URI 方案的图像)并且不加载远程图像(可以包括跟踪信息)。
If you attach all the images, then you'll usually get them showing up (while inflating your SMTP bandwidth use along with that of your recipients (which can make you unpopular)).
如果您附加所有图像,那么您通常会显示它们(同时增加您的 SMTP 带宽使用以及您的收件人(这可能会让您不受欢迎))。
回答by Levi Hackwith
I'm afraid not. The main reason email programs block images is because images are often used to 'report back' to whoever sent the email that the email has been opened. This is a common tactic used by spammers. Also, malicious code is often attached to images and downloading these images is how such code gets executed. Another reason email programs block images.
恐怕不是。电子邮件程序阻止图像的主要原因是图像通常用于向发送电子邮件的人“报告”电子邮件已被打开。这是垃圾邮件发送者常用的策略。此外,恶意代码通常附在图像上,下载这些图像就是执行此类代码的方式。电子邮件程序阻止图像的另一个原因。
回答by nosklo
No, you can't force programs you didn't write yourself to do anything.
不,您不能强迫不是自己编写的程序做任何事情。
回答by Guildencrantz
Email is hugely variable, and in general you're going to see different results in different places. That being said: There's no general way to force an email client to display images; this is why most email now includes a link at the top indicating that if it doesn't display correctly the user should click on it (which then takes the user to a standard HTML page outside the email client's image/javascript/everything-else-blocking grasp).
电子邮件变化很大,通常您会在不同的地方看到不同的结果。话虽如此:没有通用的方法来强制电子邮件客户端显示图像;这就是为什么大多数电子邮件现在在顶部包含一个链接,表明如果它没有正确显示,用户应该点击它(然后将用户带到电子邮件客户端图像/javascript/everything-else-之外的标准 HTML 页面)挡抓)。
You specifically mention gmail so it's worth pointing out that if you embed (CID URI) the images they won't show inline, they'll show as attachments at the bottom of the message.
您特别提到了 gmail,因此值得指出的是,如果您嵌入(CID URI)图像,它们不会内嵌显示,它们将显示为邮件底部的附件。
回答by amelvin
Doubt it, it would be a security issue if the 'src' of an image opened up a cross site scripting attack.
怀疑它,如果图像的 'src' 打开了跨站点脚本攻击,这将是一个安全问题。
Customers of a bank in Mexico were attacked in early 2008 with an image tag in email and were sent through their home routers to the wrong website.
墨西哥一家银行的客户在 2008 年初受到电子邮件中的图像标签的攻击,并通过他们的家用路由器被发送到错误的网站。
回答by DCD
You can, but unfortunatley Trident, which is the IE rendering engine doesn't support it (surprise, surprise), but it is technically possible to include images in the html itself - see http://en.wikipedia.org/wiki/Data_URI_scheme
你可以,但不幸的是,三叉戟,它是 IE 渲染引擎不支持它(惊喜,惊喜),但技术上可以在 html 本身中包含图像 - 请参阅http://en.wikipedia.org/wiki/ Data_URI_scheme
回答by abend
The last place I worked, we were sending out emails that had images in them that would come up automatically, in outlook at least, without me having to explicitly click a show images button.
我最后工作的地方,我们发送的电子邮件中包含会自动出现的图像,至少在 Outlook 中,我不必明确单击“显示图像”按钮。
When I inquired, another developer explained that they simply copied the encoded block of the image from an already sent email into the body of the email. I think this may be a weird sort of workaround they stumbled upon. I don't know if this adds more weight than an attachment, but I could see how an email reader would see an attachment and then ask the user as opposed to read it already in the body and just show it...
当我询问时,另一位开发人员解释说,他们只是将图像的编码块从已发送的电子邮件中复制到电子邮件正文中。我认为这可能是他们偶然发现的一种奇怪的解决方法。我不知道这是否比附件增加了更多的重量,但我可以看到电子邮件阅读器如何看到附件然后询问用户而不是在正文中阅读它并只显示它......

