vendredi 26 janvier 2018

Laravel: Queueing mails with laravel

I want to queue mails as explained at https://laravel.com/docs/5.5/mail#queueing-mail.

This is what I did so far:

  1. I changed QUEUE_DRIVER in the .env file

    QUEUE_DRIVER=database
    
    
  2. I created a job table

    php artisan queue:table
    php artisan migrate
    
    

I add a mail to the queue like this:

Mail::to($request->user())
    ->queue(new OrderShipped($order));

I setup a cronjob that will send the queried mails as explained in the docs like this:

protected function schedule(Schedule $schedule)
{
    $schedule->command('php artisan queue:work --once')->everyMinute();
}

If I would only write $schedule->command('php artisan queue:work')->everyMinute(); then the work process would never stop, so the server would be very busy at some point having a lot of parallel working processes, right?

Did I miss anything important in order to query mails with laravel? Also if I would like to send every minute at most 5 mails - how could I achieve that?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2FkdT5e
via IFTTT

Aucun commentaire:

Enregistrer un commentaire