简体   繁体   English

始终以html电子邮件和gmail显示图像

[英]Always display images in html email in gmail

I am working on a wordpress cms. 我正在一个wordpress cms上工作。 I have a little script which enable people to select posts and send it over email. 我有一个小脚本,使人们可以选择帖子并通过电子邮件发送。 The email consists of thumbnails of the selected posts. 电子邮件包含所选帖子的缩略图。 I receive them fine on my gmail email account. 我在我的gmail电子邮件帐户上收到它们的罚款。 But just as links, not as images as they were intended to be. 但是,就像链接一样,而不是像预期的那样。 Everytime I have to click "display images below" then only it displays. 每次我必须单击“在下面显示图像”时,才显示它。

Earlier I remember that it used to give this option “Always display images from” but not anymore, all I see now is this. 早些时候,我记得它曾经给这个选项“始终显示图像”,但现在不再了,我现在看到的就是这个。 Currently the image links appear as any normal link eg. 当前,图像链接显示为任何常规链接,例如。 - example link - 示例链接

目前gmail会显示此提示

Not that it is too much trouble to click "Display images below" link but it is nice when technology simply works, innit? 单击“在下面显示图像”链接不是很麻烦,但是当技术简单起作用时,它很好吗? So please let me know if you know of any particular reason this might be happening. 因此,如果您知道发生这种情况的任何特殊原因,请告诉我。

BTW, there was a similar question asked before but ended up with no solution. 顺便说一句,之前也有类似的问题问,但最终没有解决方案。 If it matters, Here is an ideal snippet from my processForm.php. 如果重要的话,这是我processForm.php中的理想片段。 Code was majorly inspired from this tutorial . 代码的主要灵感来自于本教程

$to = "awesome_dude@gmail.com";
$subject = "NEW REPORT";
$headers = "From: staff <junior@awesomeness.com>" . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message .= $_POST['message'];
$message .= '<br><br>';
$message .= $_POST ['client'];
$message .= '</body></html>';
mail($to, $subject, $message, $headers);

UPDATE: I cleared the email from the filters in hope of getting the “Always display images from” option again but nopes, same reault. 更新:我清除了过滤器中的电子邮件,希望再次获得“始终显示来自的图像”选项,但是没有,同样的原因。

As you mentioned, in Gmail there is usually a 'Always display images from...' link right after the 'Display images below' image you have in your question. 如您所提到的,在Gmail中,问题所在的“在下面显示图像”图像之后通常有一个“始终从...显示图像”链接。 I'm guessing you've already clicked this once for your own emails? 我猜您已经为自己的电子邮件单击过一次? That would explain why it no longer appears... 那可以解释为什么它不再出现了……

If Gmail is not loading the images, perhaps the html code is not correct. 如果Gmail未加载图片,则html代码可能不正确。 The 'Display images...' might just be a courtesy by gmail, as it recognizes them as images. “显示图片...”可能只是由gmail提供的,因为它会将它们识别为图片。

You'll need to post your resulting html to know for sure. 您需要发布产生的html才能确定。 Litmus Scope is a good free tool to pull the resulting html out of Gmail. Litmus Scope是一个很好的免费工具,可以将生成的html从Gmail中提取出来。

The reason you are not getting the images as you want is related to privacy protection. 无法获得所需图像的原因与隐私保护有关。 When you use images on an email you have 2 options, embed the images in the email wich results in a larger size email, or load the images from the server. 当您在电子邮件上使用图像时,有2个选项,将图像嵌入到电子邮件中会导致电子邮件尺寸更大,或从服务器加载图像。

When you link the images gmail (and many other email clients) detect the linked images and asks the user for confirmation to download. 当您链接图像gmail(和许多其他电子邮件客户端)时,检测到链接的图像并要求用户确认下载。 This may sound useless to us as developers, but email marketers as well as spammers tend to include images with unique tracking codes for example . 作为开发人员,这对我们来说可能毫无用处,但电子邮件营销人员和垃圾邮件发送者往往会包含带有唯一跟踪代码的图像。 Do you see the privacy issue on this image? 您是否在此图像上看到隐私问题?

If you want to properly embed the images on your emails check out this tutorial: 如果您想将图像正确地嵌入到电子邮件中,请查看本教程:
PHP Email: Using Embedded Images in HTML Email , it's quite old, but may get you on track. PHP电子邮件:在HTML电子邮件中使用嵌入式图像 ,它已经很老了,但可能会让您步入正轨。

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

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