Ad

Email Queuing With OctoberCMS

- 1 answer

Can anyone help with some tips on how to queue email using an OctoberCMS ajax page?

 function sendRecipientMsg($dataset, $sendCounter, $recipients){
    $template = $dataset['template'];
    Mail::queue($template, $dataset, function($message) use($dataset, $recipients){
        $message->to('[email protected]','MissPiggy');
        $message->subject('Have a good day');    
        $message->from('[email protected]',  'Mike and Stephie');
        $message->sender('[email protected]',  'Mike and Stephie');

        trace_log('$message');
        $message->cc($address, $name = null);
        $message->bcc('[email protected]', 'SAFE Campaigns Feedlots ECards');
    });
 }

This code works when we use Mail::send but not with Mail::queue

Any help or tips very welcome

Ad

Answer

In your config/queue.php file, which driver do you have set as the default?

For example: 'default' => env('QUEUE_DRIVER', 'sync')

(if you are using DotEnv then check the .env file in your docroot).

If you are using sync, it should send right away as sync is really only for development and will still block.

If you are using another method, like database, then you do have to ensure that your queues are configured to process how you expect.

Try running php artisan queue:work, then trigger your ajax call and it should send.

Ad
source: stackoverflow.com
Ad