Email thumbnail URL changed to googleusercontent.com in gmail
Asked Answered
M

6

52

I have a system whenever user upload an image, it will send an email to the registered user's gmail. But in the email, i see something like this, the thumbnail is not viewable.

enter image description here

I inspect on the element, and found the src linked to this url: https://ci5.googleusercontent.com/proxy/VI2cPXWhfKZEIarh-iyKNz1j9q7Ymh8ty4Yz19lXh82RjSlACBzS0aRajfIj913uXAsX2ylcLEDs5FBsj4cR9TcU75Pw5djdHx4htxdCAQxs_ue1Q1wi5TV43uLLBpigpjH1xN747mUHSRdTBJmXQWFyykInJCRXicM1KhNk=s0-d-e1-ft#https://www.somedomain.com/files/1658/thumbnail_71JtDozxS1L._SY450_.jpg

Obviously it is being cached by google proxy

But i can view the image without google user content, by accessing https://www.somedomain.com/files/1658/thumbnail_71JtDozxS1L._SY450_.jpg (i masked the domain so the image might not available to you).

I tried to clear browser cache but the problem still persist. How can i bypass the googleusercontent thingy or at least make the thumbnail able to display.

I checkout on this link Images not displayed for Gmail but im not using localhost and the image itself is accessible outside of my local network.

Mirella answered 23/7, 2018 at 4:32 Comment(3)
You should take a look at this question : #20904467Chapland
Can you provide the real links of the image so that it can be checked?Riffraff
sorry thought i did, thx for ur detailed answer, accepted.Mirella
P
75

How does Google Image Proxy work

The Google Image Proxy is a caching proxy server. Every time an image link is included in email the request will go to the Google Image Proxy first to see if it has been cached, if so it should serve it up from the proxy or it will go fetch it and cache it there after.

The solution for most issues

The Google Image Proxy server will fetch your images if this images:

  • have extensions like .png, .jpg/.jpeg or .gif only. May be .webp too. But not .svg.
  • do not use any kind of query string part in the image URL like ?id=123
  • have an URL which is mapped onto the image directly.
  • have not a long name.

Requirements for image server:

  • The response from image server/proxy server must include the correct header like Content-Type: image/jpeg.
  • File extension and content-type header must be in the same type.
  • Status code in server response must be 200 instead of 403, 500 and etc.

What could help too?

Google support answer:

Set up an image URL proxy whitelist

When your users open email messages, Gmail uses Google’s secure proxy servers to serve images that might be included in these messages. This protects your users and domain against image-based security vulnerabilities.

Because of the image proxy, links to images that are dependent on internal IPs and sometimes cookies are broken. The Image URL proxy whitelist setting lets you avoid broken links to images by creating and maintaining a whitelist of internal URLs that'll bypass proxy protection.

When you configure the Image URL proxy whitelist, you can specify a set of domains and a path prefix that can be used to specify large groups of URLs. See the guidelines below for examples.

Configure the Image URL proxy whitelist setting:

  • Sign in to your Google Admin console. Sign in using your administrator account (does not end in @gmail.com).
  • From the Admin console Home page, go to Apps > G Suite > Gmail > Advanced settings. Tip: To see Advanced settings, scroll to the bottom of the Gmail page.
  • On the left, select your top-level organization.
  • Scroll to the Image URL proxy whitelist section.
  • Enter image URL proxy whitelist patterns. Matching URLs will bypass image proxy protection. See the guidelines below for more details and instructions.
  • At the bottom, click Save.

It can take up to an hour for changes to propagate to user accounts. You can track prior changes under Admin console audit log.

Guidelines for applying the Image URL proxy whitelist setting

Security considerations

Consult with your security team before configuring the Image URL proxy whitelist setting. The decision to bypass image proxy whitelist protection can expose your users and domain to security risks if not used with care.

In general, if you have a domain that needs authentication via cookie, and if that domain is controlled by an administrator within your organization and is completely trusted, then whitelisting that URL should not expose your domain to image-based attacks.

Important: Disabling the image proxy is not recommended. This option is available to provide flexibility for administrators, but disabling the image proxy can leave your users vulnerable to malicious attacks.

Entering Image URL patterns

To maintain a whitelist of internal URLs that'll bypass proxy protection, enter the image URL patterns in the Image URL proxy whitelist setting. Matching URLs will bypass the image proxy.

A pattern can contain the scheme, the domain, and a path. The pattern must always have a forward slash (/) present between the domain and path. If the URL pattern specifies a scheme, then the scheme and the domain must fully match. Otherwise, the domain can partially match the URL suffix. For example, the pattern google.com matches www.google.com, but not gle.com. The URL pattern can specify a path that's matched against the path prefix.

Important: Enter your actual domain name as you enter the image URL pattern. Always include a trailing forward slash (/) after the domain name.

Examples of Image URL patterns

The following patterns are examples only. The following patterns:

http://rule_fixed_scheme_domain.com/
rule_flex_scheme_domain.com/
rule_fixed_subpath.com/cgi-bin/

... will match the following URLs:

http://rule_fixed_scheme_domain.com/
http://rule_fixed_scheme_domain.com/test.jpg?foo=bar#frag
http://rule_fixed_scheme_domain.com
rule_flex_scheme_domain.com/
t.rule_flex_scheme_domain.com/test.jpg
http://t.rule_flex_scheme_domain.com/test.jpg
https://t.rule_flex_scheme_domain.com/test.jpg
http://rule_fixed_subpath.com/cgi-bin/
http://rule_fixed_subpath.com/cgi-bin/people

Note: The URL scheme (http://) is optional. If the scheme is omitted, the pattern can match any scheme, and allows partial matches on the domain suffix.

Previewing the image URL patterns

Click Preview to see if the URLs match the image URL patterns you've set. If the image URL matches a pattern, you'll see a confirmation message. If the image URL does not match, an error message appears.

Puffball answered 1/8, 2018 at 23:59 Comment(8)
Greeting,we have the same issue. We dont want to change our file name, so it comes to these 2 options, wait for the cache to expire or setup the whitelist described above. How long will it take for the cache to expire? I tryed to create an admin account (not ending @gmai.com ) but it seems i have to create a workspace account..Rustice
Thanks for your answer, but what does have an URL which is mapped onto the image directly. mean?Procreate
the "But not .svg." was the important bit for me that I didn't know.Stour
I solved this by adding Google's proxy IPs to Cloudflare's WAF allow listImmunochemistry
The problem I am seeing is then I first view an email on an iPhone (using native mail app), I need to do a lot of "Load content" taps to view the images - I presume if gmail hadn't proxied the images, then then they would have displayed as they would be on the same domain as the sender...Unadvised
@d0m3, this mean without redirecting.Puffball
If the image name contains spaces they will be changed to "+" which works in the browser's address bar and html but not here in the email.Manvel
@DennisBareis, "+" it’s not the standard replacer for spaces. Some web servers have realised this, but not all. It has also nothing to do with browser's functionality. The standard replacer for space sign is "%20" and this works always (on all servers and browsers).Puffball
E
3

Bharata has a great and detailed answer on this, but just wanted to add one addition that I identified with a similar issue.

We had a x-webkit-csp content security header that turned out to be the culprit. Removing it and all worked through the image proxy.

Google's response was that x-webkit-csp is deprecated and to use the Content-Security-Policy header instead. However this seems like a bug that an unsupported header throws a fatal error rather than simply ignoring it.

Eicher answered 25/10, 2018 at 5:54 Comment(0)
S
2

TL;DR: Make sure your server isn't blocking external connections (through AWS or .htaccess or some other firewall)!

I was having this problem too. I ran through every solution I could think of and every one I found online. Nothing fixed it.

Finally, I inspected the image in Gmail so that I could get the full CDN address Google creates for it. I tried to open that in a new tab and it failed. So I realized that Google wasn't able to grab the image.

In the end, I'd forgotten that I have the server locked down from all traffic except for my own (just a basic .htaccess IP deny). It's just a simple security layer I use while I'm in my development. Keep in mind that you might have it locked down within AWS or something more rugged like that.

I opened up all IPs for a minute, tested it, and sure enough it worked as expected. The old emails that were previously failing also worked, so it seems that Google tries to work their magic anytime the email is opened and they don't have the image saved. Once I closed the IP address again, the image continued to work whatever Google. I'm guessing once they write it to their CDN is remains there indefinitely.

So if you're certain that you've done everything else correctly, I would suggest making sure that the server is indeed open to the outside world so Google can process the image.

Sunburn answered 11/7, 2021 at 8:55 Comment(0)
D
0

I had the same problem and I solved it by specifying the "https://" protocol in the "src" url of the img, otherwise by default "http" is prepended

Dom answered 17/3, 2022 at 5:15 Comment(1)
Welcome to StackOverflow. Before answering a question, read it carefully. In this case, the solution you provided doesn't fit with the question. Look at the links shared in the question: The https is there, so that's not the problem.Myrtice
M
0

Solved this issue by finding out that for Google mydomain.com was an external domain to mail.mydomain.com lol

Replaced all my mydomain.com/img.jpg by mail.mydomain.com/img.jpg

Now it works

Btw: webp is a google extension of course they accept it in priority and give you bad seo when you don't use it lol

Mori answered 18/3 at 5:3 Comment(0)
E
0

I had the same issue and it turned out it was my hosting that was blocking it (never figured out why it was blocking some images and not others). Adding a rule excluding the User-Agent containing GoogleImageProxy immediately solved it.

Egest answered 17/6 at 21:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.