4

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
Yasin Patel
  • 5,624
  • 8
  • 31
  • 53

5 Answers5

5

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

lagbox
  • 48,571
  • 8
  • 72
  • 83
1

Use public_path() in place of url() or assets(). public_path() is working for me.

ahuemmer
  • 1,653
  • 9
  • 22
  • 29
0

Try to use url helper like this: {{ url('/images/logo.png') }}

Alex
  • 2,707
  • 4
  • 29
  • 42
0

Provided that you've updated .env from localhost to app.site_domain.com while queue worker was running, you might want to restart supervisor / worker queues. Clearing and re-caching config will not update the settings in supervisor (that is, of course, if you are using supervisor to manage queues).

user3532758
  • 2,221
  • 1
  • 12
  • 17
0

You not get image from local.You should upload this image on server .Then give that server image link. Now you can get this image on email. You can check this by using an image. or try using embed($pathToImage) }}">

albus_severus
  • 3,626
  • 1
  • 13
  • 25