Skip to content
Advertisement

images not appear in the blade page if send it to email by using queue job Laravel?

I send an email to user for verifying, by using queue job after registration, the job run successfully but the (blade page), which sent to the user doesn’t show the images, Although if I sent the blade page without send it by queue job, the images appear fine!?

So the issue is that:

  • the images in the blade page in the user’s email inbox, doesn’t appear if I sent it by using the queue job, Although if I sent it directly without queue job, it appear fine.

image’URL if I sent it by using queue job:

http://localhost/assets/img/logo.png

enter image description here

image’URL if I sent it without using queue job:

http://localhost:8000/assets/img/logo.png

enter image description here

The Blade Page

JavaScript

Route:

JavaScript

Controller:

JavaScript

queue job:

JavaScript

Mail class:

JavaScript

Any Help

Advertisement

Answer

I have faced this issue before. For emails all path must be a Fully Qualified URL. Because queue jobs can not smartly figure out what the application’s base url should be.

https://example.com/static/logo.png is a Fully Qualified URL, but /static/logo.png isn’t. For this, I use a APP_URL env key.

When a action is being performed without http request(Like in queue system), laravel can not translate /static/logo.png to https://example.com/static/logo.png

On .env file I’d do something like

JavaScript

The on the view file, I’d do something like

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement