0
  • I have two mailable clasess: Notification and UserRegister

  • On develop environment both work fine

  • On production environment only Notification works properly.

  • In this case, UserRegister works if it's sent directly but not when queued. It tries till 255 attempts are reached and then it stops.

      Mail::to($address)->send(new UserRegister($user)); // works fine
      Mail::to($address)->queue(new UserRegister($user)); //it doesn*t work. Always on queue
      Mail::to($address)->later($when,new UserRegister($user)); //it doesn*t work. Always on queue
    
  • I have cleared all caches in production. I have executed "composer dump-autoload".

  • My .env parameter for queue is database on both environments:

QUEUE_DRIVER=database

  • I have restarted the production server
  • There could be something wrong on my supervisor configuration?
  • No idea what else I should do

Thanks for any help

3 Answers3

0
php artisan queue:work --tries=1 --verbose
[2023-03-16 11:57:41][11304] Processing: App\Mail\UserRegister
[2023-03-16 11:57:41][11304] Failed:     App\Mail\UserRegister

php artisan queue:failed
+----+------------+---------+------------------------------------+---------------------+
| ID | Connection | Queue   | Class                              | Failed At           |
+----+------------+---------+------------------------------------+---------------------+
| 1  | database   | default | Illuminate\Mail\SendQueuedMailable | 2023-03-16 11:57:41 |
+----+------------+---------+------------------------------------+---------------------+
0

Please verify the below task and try again

  • The problem happens if the queue worker not running on the production server.
  • The 'config/queue.php' is not set up properly.
  • The 'queue' table is not found.
  • When emails are not saved in the correct table.
  • You have too many emails so the queue needs more time but timeouts are too quick. So need to increase the time.
  • If you are using Supervisor to manage the queue worker, but you do not update the configuration file (/etc/supervisor/conf.d/yourapp.conf) correctly and when directory paths are not correct for the production environment.

If you need more information about the queue then please go to "https://laravel.com/docs/10.x/queues#main-content".

0

ISSUE AND SOLUTION IS IN SUPERVISOR!!. The problem is solved. I was using queue:work to run my queue. Running the queue with queue:listen solved the issue.