Nurrohman
Nurrohman

Reputation: 43

image not found in gmail from laravel

how to display images from local, so they can appear in gmail I have tried it as below

{{ $message->embed(public_path().'/images/img/rounder-up.png') }}

but the image still isn't found

Upvotes: 2

Views: 1948

Answers (1)

Haritsinh Gohil
Haritsinh Gohil

Reputation: 6272

So you are sending your local image path in gmail to display image but before showing the image in gmail google proxy tries to access the url and because image is available in your local only so google can't access it via proxy and so it does not appear in your gmail,

and if you inspect your image in gmail you can check that google proxy also append your url with some random string URL like below:

https://ci5.googleusercontent.com/proxy/P6DZncgANd5glVi64ElKhesSE10SH6iAhu2FOSF3jJtgaWGUHsqwOn6iDwHE86unvlD9Xi6cSZp0T4u1N_KHhBY-TxFaV8PfKYRMEH5b=s0-d-e1-ft#http://localhost:8000/public/images/img/rounder-up.png

and if you remove the part before # then it will appear in gmail too, but it is appearing because localhost is running in your computer

The solution is to ensure that the path you are using is one accessible outside of your local network; for example, by hosting the images on an externally-facing server

or if you are working on your site which later you will host it on any hosting server then after going live the images will appear.

because google want that the images should be somewhere on the internet not on the local so it can fetch it.

Upvotes: 2

Related Questions