Skip to content
Advertisement

image not displaying in mail in queue – laravel

In my mail template I used image path as below :

<img src="{{ URL::to('/images/logo.png') }}" alt="logo" download="false" style="width:50%">

It is working with normal mail (without the queue) but not in mail in queue.

By inspecting element in mail i found that when for normal mail image path is as below :

https://app.site_domain.com/images/logo.png //as expected 

But for mail queue it is :

http://localhost/images/logo.png

Advertisement

Answer

You have to set a URL for your application for the Console commands to know what URL to use for your application for URL generation as there is no webserver passing the request information to it.

You can set APP_URL in your .env file for this.

APP_URL=https://app.site_domain.com

By default it is set to http://localhost, which is why that is showing up.

If your configuration is cached you will need to clear it or cache it again:

php artisan config:cache 

You will need to stop the queue workers most likely, (command to make the queue workers die after processing any current jobs):

php artisan queue:restart

Then you can start them up again, or hopefully you have something monitoring those processes and will restart them after they die.

Laravel 6.x Docs – Configuration – Configuration Caching

Laravel 6.x Docs – Queues – Queue Workers & Deployment

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