简体   繁体   English

如何强制电子邮件程序显示使用PHP在html电子邮件中发送的图像?

[英]How can I force email programs to show images send in html email using php?

I am sending an html email with php and it includes an image. 我发送一个带有PHP的HTML电子邮件,它包含一个图像。 Some email programs, such as gMail have a 'display images' button. 某些电子邮件程序(如gMail)具有“显示图像”按钮。 The user has to click on that in order for the images in the email to show up. 用户必须单击该按钮才能显示电子邮件中的图像。

Is there any way I can force email programs to show images that are sent within html emails generated by php? 有什么方法可以强制电子邮件程序显示在php生成的html电子邮件中发送的图像吗?

As a rule of thumb, email clients are configured to display attached images by default (eg 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带宽与您的收件人一起使用(这可能会让您不受欢迎))。

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. 邮件程序阻止图像的另一个原因

不,你不能强迫你没有写自己的程序做任何事情。

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 /所有其他的标准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)它们不会内联显示的图像,它们将在消息的底部显示为附件。

Doubt it, it would be a security issue if the 'src' of an image opened up a cross site scripting attack. 毫无疑问,如果图像的'src'打开了跨站点脚本攻击,那将是一个安全问题。

Cross site request forgery 跨站点请求伪造

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年初受到了电子邮件中的图像标记攻击,并通过其家用路由器发送到了错误的网站。

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... 我不知道这是否比附件增加了更多的重量,但我可以看到电子邮件阅读器如何看到附件,然后询问用户,而不是在身体中读取它并只显示它...

你可以,但不幸的是Trident,这是IE渲染引擎不支持它(惊喜,惊喜),但技术上可以在html本身中包含图像 - 请参阅http://en.wikipedia.org/wiki/ Data_URI_scheme

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

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