skip to Main Content
  • 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

Answers


  1. Chosen as BEST ANSWER
    php artisan queue:work --tries=1 --verbose
    [2023-03-16 11:57:41][11304] Processing: AppMailUserRegister
    [2023-03-16 11:57:41][11304] Failed:     AppMailUserRegister
    
    php artisan queue:failed
    +----+------------+---------+------------------------------------+---------------------+
    | ID | Connection | Queue   | Class                              | Failed At           |
    +----+------------+---------+------------------------------------+---------------------+
    | 1  | database   | default | IlluminateMailSendQueuedMailable | 2023-03-16 11:57:41 |
    +----+------------+---------+------------------------------------+---------------------+
    

  2. 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".

    Login or Signup to reply.
  3. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search