3

I've used django python-postmark for mailing. Now my problem is that my static images are not shown on Gmail. Gmail prepends a url proxy to the src of the images. if the prepended url proxy is removed, the image will show perfectly. What am I missing here? or how do I fix this? thanks

These are my code for the image. this supposed to result to src="https://mysite_here.com/static/img/img.png"

{% load static %}
{% load custom_tag %}
<img src="{% site_url %}{% static 'img/img.png' %}">

But upon showing on gmail, the src is now prepended which causes the image to not show. Here's what the gmail generated:

<img src="https://ci3.googleusercontent.com/proxy/rYDcSW7inrn8_vlXhcrSojT1T06pKEKyrzmXgb5cje_JCc9ze25emLbFDuBub3CWP_ASqgUXbqn6RureN5Fy0Nd-eFdllL14aq16UQ_rXrB4-dWp=s0-d-e1-ft#https://mysite_here.com/static/img/img.png" class="m_-186473825407072632logo CToWUd">
Christopher
  • 418
  • 1
  • 5
  • 19
  • Is the correct img URL supposed to be `https://mysite_here.com/static/img/img.png` or `https://mysite_here.com/img/img.png` ? What happens when you enter the gmail img src address in your browser? I'm guessing a '404 Not Found'. – aneroid Oct 25 '18 at 09:27
  • the correct url should be `https://mysite_here.com/static/img/img.png` .. the problem is that the gmail prepends a proxy url to the correct url... if I manually remove the prepended proxy url, it'll show no probs ( `https://mysite_here.com/static/img/img.png`). – Christopher Oct 25 '18 at 09:50
  • 1. When you click "Show pictures" in Gmail, does it load after that? 2. from before: What happens when you enter the gmail img src address in your browser? – aneroid Oct 25 '18 at 09:53
  • 1. No, I've already checked that option on. 2. Also no, it only shows if I remove the prepended proxy url. – Christopher Oct 25 '18 at 09:55
  • Looks like your website hosting co. might be blocking requests from `googleusercontent.com`. Check with them. – aneroid Oct 25 '18 at 09:57
  • Could be. but wont that supposed to show error 500+? it's showing 404. – Christopher Oct 25 '18 at 10:16
  • Depends on how they block - they could use any error code they like. I hope you're not trying this while your site and `img.png` are running on 'localhost'. – aneroid Oct 25 '18 at 10:18
  • It's hosted. it's on https. – Christopher Oct 25 '18 at 10:20

2 Answers2

1

I was testing when Gmail request the image, using python SimpleHTTPServer, as suggested in this post: https://blog.filippo.io/how-the-new-gmail-image-proxy-works-and-what-this-means-for-you/ and realized that the image was actually been reached.

The problem was that I was serving a .svg image. I realized this was the error by reading this another question: https://webmasters.stackexchange.com/questions/123969/images-from-googleusercontent-com-giving-404.

Once I replaced the image for a .png and .jpg it started to work.

Hope this can give some light. I don't really know why Gmail can't handle .svg

kliank
  • 31
  • 5
0

Personally, I solved this issue by writing out <img src="https://.."> in the image source URL. For some reason, Postmark does not deliver the images properly if written simply <img src="//domain.com">. I'm not sure why this breaks but adding the https solved it for me.

kaleazy
  • 4,966
  • 2
  • 40
  • 47