Gmail の新しい画像キャッシュにより、ニュースレター内の画像リンクが壊れる 質問する

Gmail の新しい画像キャッシュにより、ニュースレター内の画像リンクが壊れる 質問する

私のサイトでサインアップが完了すると、自動的に送信されるメールがいくつかあります。

最近まで問題なく動作していました。Googleの新しいシステムは画像を書き換えてキャッシュに保存している(と思われる)

しかし、Google が画像リンクを新たに書き換えたため、リンクが完全に壊れてしまい、500 エラーとリンク切れ画像が表示されます。

私の通常の画像 URL は次のようになります:

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

Google はこれを次のように書き換えます。

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

しかし、その URL には何もありません。

画像エラーを示すメール

つまり、Google によって作成されたリンクに問題があるか、画像が googleusercontent サーバーにアップロードされていないかのどちらかですが、問題を解決する方法がわかりません。

私はPHPを使用しています。phpmailer ライブラリAmazon EC2 上の Ubuntu サーバーですが、これが問題に関連しているかどうかはわかりません。

ベストアンサー1

GoogleImageProxy の問題を解決できたと思います。

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 on 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, and 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 thousand times. 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.

GoogleImageProxy has set its own expiry date for the images. I think one month. so now the fresh copy of images will be fetched after the expiry date. I mean after one month. You can not force GoogleImageProxy to fetch the images. But it is 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
  • ファイル拡張子とコンテンツタイプヘッダーは一致する必要があります
  • ステータスコードは403、500などではなく200である必要があります

重要な注意点

PHP メール スクリプトを実行するたびに、プロセス全体を繰り返すようにしてください。GoogleImageProxy は毎回画像をキャッシュするため、新しい試行ごとに同じプロセスを繰り返す必要があるためです。

これでほとんどの人にとって問題が解決することを願っています。

おすすめ記事