Domantas Šlaičiūnas
Domantas Šlaičiūnas

Reputation: 369

Laravel gmail not rendering my mail images

I trying to send an email to a User, but for some reason, my images are not rendering and I getting: enter image description here. When I try to Inspect Element in Gmail, my images src are not correct:

https://ci5.googleusercontent.com/proxy/BAKUQWuXu4XR7w4v6hboZ0E9LQlwspSfcV4K1tkK6rgoPeQrt0b0J-Q2ndKdbTAV5-XJa4yrVHuTKpBy24_Q-QWt7PnLFY0VanfclSmZrTgg=s0-d-e1-ft#http://test.com/images/email_upload/my-image.png 

Correct Url:

http://test.com/images/email_upload/my-image.png 

This is my template:

<a href="#" style="color: #4cb2e1; font-weight: lighter; text-decoration: none">
    <img src="{{ asset('images/email_upload/my-image.png') }}" width="150" height="50" style="margin-left: 20px; margin-right: 12px" align="left">
</a>

P.S. I using Laravel mailable.

Upvotes: 0

Views: 1831

Answers (2)

Supun Madhushanka
Supun Madhushanka

Reputation: 139

try this embeded method embed(public_path('/images/logo.svg')) }}">

Upvotes: 0

Synchro
Synchro

Reputation: 37760

This is a Gmail "feature"; They precache images referenced from email messages and rewrite URLs to point at their own copies, purportedly as a way of reducing load and blocking tracking pixels. To be sure you're actually sending the correct content, BCC yourself at a non-gmail address and then compare the resulting received messages to see exactly what gmail is changing.

One fundamental issue is that you don't seem to be serving images over HTTPS; that's mostly considered a bug these days.

A side-effect of this is that received messages cannot be reverified for DKIM, which at least partly undermines the point of DKIM.

There is further discussion of this problem in this excellent answer, and others answers to that question. Unfortunately the consensus seems to be that Google's image caching system is buggy, but that's nothing new as far as gmail is concerned.

Upvotes: 2

Related Questions