Gmail's new image caching is breaking image li

2020-01-24 10:34发布

I've got some automatic emails that are sent out upon signup completion for my site.

Until recently, they worked fine. Now Google's new system is rewriting the images and storing them in it's cache (supposedly)

However, Google's new rewriting of my image links are completely breaking them, giving a 500 error and a broken link image.

Lets say my normal image url is:

http://www.mysite.com/images/pic1.jpg

Google is rewriting this to:

https://ci5.googleusercontent.com/proxy/vI79kajdUGm6Wk-fjyicDLjZbCB1w9NfkoZ-zQFOB2OpJ1ILmSvfvHmE56r72us5mIuIXCFiO3V8rgkZOjfhghTH0R07BbcQy5g=s0-d-e1-ft#http://www.mysite.com/images/pic1.jpg

However, there is nothing at that URL.

Email showing image errors

So, either there is something wrong with the links that are being created by Google or the images are just not being uploaded to the googleusercontent server, but I have no idea how to solve the issue.

Im using PHP, the phpmailer library and a Ubuntu server on Amazon EC2, but Im not sure that is related to the issue.

15条回答
ゆ 、 Hurt°
2楼-- · 2020-01-24 11:22

I know this is an old question but the same thing happened to me. When I checked my access logs this is what I found -

www.example.ca 66.249.85.50 - - [10/Apr/2014:17:57:18 -0400] "GET /newsletters/Apr10_2014/cad/cad2.jpg HTTP/1.1" 403 457 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7 (via ggpht.com GoogleImageProxy)" 

You can see that my server was blocking the GOOGLEIMAGEPROXY giving it a 403 Forbidden reply. I decided to check my .htaccess and sure enough I was blocking the term PROXY. After removing the term, the images appear just fine now on Gmail. Hope that helps.

查看更多
叛逆
3楼-- · 2020-01-24 11:22

HTTPS image locations do cache. Several of our production environments have no problems with gmail proxying image locations using a HTTPS uri. I could see gmail ignoring your content if the SSL certificate is invalid in some way.

查看更多
劳资没心,怎么记你
4楼-- · 2020-01-24 11:24

I have a perfect solution of this problem, which worked for me if you are using PHPMailer then you just have to add another option in PHPMailer for attaching image like this

$mail = new PHPMailer(); $mail->AddEmbeddedImage('../absolutepath/image/image.jpg', 'logoimg', '../absolutepath/image/image.jpg');

Here we have given absolute path of image and give it a name call 'logoimg' or whatever you want.

Now you can add this logoimg to wherever in your HTML Body like this

$mail->Body = " <h1>Test of PHPMailer html body with image</h1> <p>This is a test picture: <img src=\"cid:logoimg\" /></p>"; $mail->send();

That's All.

查看更多
家丑人穷心不美
5楼-- · 2020-01-24 11:26

In my case the size of file was the problem, it was 22 Mb (i know right?), and after we reduced the size everything started working like a charm.

Check file size and if it's too big, compress it.

查看更多
放我归山
6楼-- · 2020-01-24 11:26

I know this is an old question but I've met this problem. In my case images are stored at Google Cloud Storage. What is interesting is that link

https://storage.cloud.google.com/{bla_bla}/logo.png

returns 307 (temporary redirect) and Location header containing something like

https://{xxx}-apidata.googleusercontent.com/{bla-bla_bla}/logo.png?{zzz}

Seems like GoogleImageProxy does not process 307 correctly

查看更多
登录 后发表回答