117

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.

RonnyKnoxville
  • 5,103
  • 9
  • 37
  • 67
  • do you have any security feature in your server or logic serving the image ? is it available only for a limited time or this kind of features ? – Pixou Jan 06 '14 at 07:01
  • There is no kind of security feature or login system to view the images, they are in a public folder in the system. If you visit the original link the images is viewable. The issue is that the Google's rewriting of the url is either not uploading the image to their servers or not correctly directing the user to my site. – RonnyKnoxville Jan 06 '14 at 09:58
  • 1
    After blogs and posts review, there is no real workaround found for this random issue (March 2013). I am wrong ? – kheraud Mar 17 '14 at 22:04
  • 4
    this is driving me absolutely insane. google has broken email. i've been active in several related threads on the google forums and can get no traction. this has been broken since early December 2013. – Nathan Beach Mar 28 '14 at 15:51
  • Has this gone anywhere? I'm pulling my hair out. Images are publicly accessible, load fine when going directly to them, content type matches and google's proxy server is getting nothing but 200 OKs in my logs. I have no idea why the images won't show up in gmail. – Matt Brunmeier May 21 '15 at 05:04
  • @epalla I never got to the bottom of this unfortunately. – RonnyKnoxville May 22 '15 at 12:19

16 Answers16

96

I think I have figured out the GoogleImageProxy issue.

This is something related to CACHING concept. suppose, you have recently deployed your php code on your server but you forgot to upload images. you tested once with your email logic. your system generated an HTML email. When this email will hit the gmail server GoogleImageProxy will try to fetch and store the images from your site to its own proxy server. while fetching the images, GoogleImageProxy found some 404 statuses against your missing images and 403 against some protected images. GoogleImagesProxy has stored these statuses into its own proxy server.

Now tried to open your email, you noticed some 404 statuses against your images. This is something understandable. You immediately realized that you forgot to upload some images, so you uploaded them to your server. and also you have fixed some permissions against protected images.

You are all done now. Now you try to run your php-email script once again. As a result you receive another email in your Gmail or Hotmail inbox. you had fixed all the issues with your images. Now the images must be displayed in your email content. but you are still unable to see the images.

Ah, possibly you forgot to clear your browser's cache. Clear your browser's cache and load the gmail or hotmail page once again. But the result will be still the same. Try to apply dozens of fixes/patches and try to run your php-email script a thousands time. But the result will be still the same. No improvement.

THE REAL PROBLEM

What the hell is going on? Let me explain it to you. Go to your access log and try to find requests from GoogleImageProxy. You'll be surprised to see that there will be only 2 or 3 three requests from GoogleImageProxy depending on the number of different images used in your email. GoogleImageProxy never tried to fetch images Even after you have fixed the issues with your images by uploading missing images and setting permissions for protected images. Why? Clearing your browser's cache has no impact. GoogleImageProxy will never fetch the fresh images even for your newer email because the images are now cached into GoogleImageProxy along with their last status code and not cached in your own browser's.

GoogleImageProxy has set its own expiry date for the images. I think one month. so now the fresh copy of images will be fetch after expiry date. I mean after one month. You can not force GoogleImageProxy to fetch the images. But its important for you to display images in your email. What can be the solution?

THE SOLUTION

Following is the only way to force GoogleImageProxy to fetch your images

  • Rename your images to something else with png, jpg or gif extensions only.
  • Don't use any kind of query string in your image url like ?t=34343
  • your image must include png, jpg or gif as an extension.
  • your image url must be mapped onto your image directly.
  • If you need to use some proxy url for your protected images then your response must include the proper header like Content-Type: image/jpeg
  • File extension and content-type header must match
  • Status-code must be 200 instead of 403, 500 etc

IMPORTANT NOTE

Try to repeat the whole process for every run of php-email script. because every time GoogleImageProxy will cache your images and you'll have to repeat the same process for every new try.

Hopefully this will fix the issue for most of the people.

hemflit
  • 2,649
  • 3
  • 19
  • 17
Malik Ahmed Khan Awan
  • 1,510
  • 1
  • 13
  • 14
  • Thanks for updating this issue, it sounds like a real possible solution. Unfortunately its been years since I posted this issue so I guess the images no longer exist on the proxy server, but its good to finally get an answer to this! – RonnyKnoxville Dec 23 '15 at 14:51
  • 12
    tl;dr: your probably using .svg, use .png .jpg or .gif instead – taylorstine Jan 26 '16 at 20:24
  • 2
    yeah, don't use svg ;) – Alexandre Martini Jun 19 '18 at 05:38
  • For the problem of GoogleImageProxy caching a 404, I found safin chacko's solution of forcing a refresh from the browser worked for me: https://stackoverflow.com/a/49292512/1000655 . I almost didn't try it, because (I think) this accepted answer says I would have to change the filename, which I can't do for an email I already accidentally sent out. I'm glad GoogleImageProxy is honoring browser requests to check for new versions of images! – Neal Gokli Jul 30 '18 at 23:20
  • 1
    We had an image being served from Azure Blob Storage that had a space in the file name. The image wouldn't show correctly in Gmail. When we removed the space in the file name it fixed the issue. – Narthring Oct 31 '18 at 14:24
  • 1
    @AlexandreMartini why not use SVG? Logo is best in SVG, no? – trainoasis Jan 27 '19 at 21:16
  • @hemflit no it did not work i changed the whole image url before making it live to google i tested whether the image is visible at my browser and then added the link to the templates. – insoftservice May 12 '19 at 13:03
  • The user is clearly using .jpg so not sure why it is mentioned in answer. Outlook works like a charm. So what is gmail doing? – Blue Clouds Oct 22 '19 at 15:29
  • 2
    Make sure that you urlencode your image paths. We had a space in the path, and though browsers will replace it with a %20, gmail cache does not and considers it a broken link. – crichavin May 19 '20 at 00:37
  • 1
    I have this problem on emails that have been going out fine for 15 years, nothing changed. All I can think is that when Google did its monthly cache it couldn't reach our server for some reason (that's super unlikely though, and why on earth wouldn't it retry if it can't find it). This is very low quality work from Google. – niico Sep 14 '20 at 09:33
30

Based on your example, it looks like you are using traditional extensions (.jpg, .png, .gif). Some folks on this thread, describing the same issues you are facing, have stated that using those extensions solves the problem.

Other possible solutions:

Community
  • 1
  • 1
JSuar
  • 20,558
  • 4
  • 40
  • 80
  • 1
    These are a lot of the sources I'd found when researching this problem myself, unfortunately none of them give me the answer Im looking for. Im still hoping that Google will resolve this issue before I manage to find an answer – RonnyKnoxville Jan 09 '14 at 11:14
  • @JackalopeZero have you tried to independently replicate this issue outside the newsletter? I tried it on my personal and company gmail with successful results. I know it's a problem but maybe creating a new email with images could shed light on what's occurring. – JSuar Jan 10 '14 at 14:43
  • 4
    Thanks for the tip on extensions. I was using `.svg` images, and those are [confirmed](http://stackoverflow.com/a/21064771/1057616) not to be supported by Google's proxy. – Nick Merrill Jan 30 '14 at 07:10
  • 1
    I ran into this myself today. For me, Google's proxy was throwing a 500 error for 1x1 transparent `pixel.gif`. Changing this to a 1x1 transparent `pixel.png` and the proxy served up as expected. Weird. – deefour Mar 07 '14 at 23:02
8

I was having a similar issue, but it was caused by the length of the URL. Google generates the following URL when caching an image from gmail:

https://ci4.googleusercontent.com/proxy/[hash]#[url])

The hash generated is based on the URL of the image, but the size will vary based on characters used. I ran several tests with different sized URLs, and found the cached image would fail to load consistently (400/Invalid Request) if the hash exceeds 2076 characters in length (close to 2048 bytes + meta? not sure).

Again, the image URL could generate a hash that exceeds this many characters at ~1000 special characters, or 1500+ simple characters. If the hash exceeds 2076 characters in length, the request fails.

I realize this is an old post, but hopefully this helps other devs scouring Google

Mahdi.Montgomery
  • 1,976
  • 3
  • 16
  • 19
6

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.

Manish Pradhan
  • 1,041
  • 9
  • 25
  • I also had a 403. I figured out that mod_security is blocking the Google proxy... – Peter Jan 13 '15 at 08:47
  • 2
    This was exactly the issue I had. You can test if you're having the same configuration issue using curl: ```curl -I --user-agent "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)" -X GET https://example.com/your-image.png``` – Dave Teare Sep 07 '15 at 16:58
3

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.

DDS
  • 603
  • 6
  • 7
  • Thanks for the update. Although it was a while ago now I never found a solution to this answer – RonnyKnoxville Nov 21 '14 at 11:09
  • Depending on my current experience trying to create html emails with images included and with https protocols, I confirm that it depends on the certificate. Using let's encrypt with no organization in it, the image is blocked in Gmail. While using a branded certificate with the organization included, well the image shows up. So I guess it's either free vs branded certificates or the organization declared in it. – Tritof Feb 15 '18 at 17:04
3

I just tried , after replacing the image (without changing image name)

  • Open email in new browser , it shows new image

  • Ctrl+f5 (forces a cache refresh) in the chrome (my default browser) , also shows new image

safin chacko
  • 1,324
  • 1
  • 9
  • 18
1

Check that the content-type returned for the image file by your server is correct.

You can check this using Fiddler.

Softlion
  • 11,311
  • 10
  • 52
  • 78
1

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.

vishes_shell
  • 17,549
  • 6
  • 59
  • 68
  • Nice catch. Gmail's error message makes it seem like it was a typing error or permissions error, which was very misleading. – Luminaire Jul 14 '18 at 19:46
1

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

askazakov
  • 21
  • 1
  • 4
0

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.

Arjun Choudhary
  • 183
  • 2
  • 14
0

I had this issue when I was sending gifs. I found that the file size matters to Googles Proxy server. I suggest making the files as small as possible and see if that works. You can use your Gmail account and add a photo from a URL to test. If the gif shows up when you are composing your email it will be receivable.

happy coding.

0
  1. Is it working from Outook/hotmail? It should then we can isolate it as google issue. In your case it is not.
  2. Size of the image can be a problem. Try to reduce it and see
  3. www.mysite.com this site might be accessible from your system. But is it also accessible from google server?
  4. Try changing extension.. this is the trick: You might have tried several things but it would still fetch from cache(which invalidates your efforts) but when the extension changes, it fetches again and all the work you did before comes into play and if it works you might think it is the 'extension' that did the trick!! (like many of those who speaks about extensions)
Blue Clouds
  • 4,483
  • 2
  • 30
  • 53
0

In my case of running into this issue, the problem was that accidentally the path to the image in the email template had triple slashes in the URL, e.g. https:///content.example.org/image.png. This was hard to spot, and while it was working in other email clients who could successfully resolve the URL, Google's image proxy wasn't able to handle it and resulted in a 404 for the proxied image address.

Adam Reis
  • 3,106
  • 35
  • 27
-2

Make sure that Gmail is request your image over http, not https.

Lets say your normal image url is:

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

So change to:

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

I have a strong feeling that google's proxy don't cache https.

Pedro Vagner
  • 8,029
  • 3
  • 26
  • 19
-7

It's March 6 and you've probably already figured this out, but thought I'd chime in to help others. I discovered that JPGs don't work in gmail. The PNG format works great. Sorry I can't explain why, but sometimes it's better not to ask why. Use PNG!

MaryM
  • 27
  • 1