6 months ago

Scheduling sending multiple queued mails

Posted 6 months ago by Gabotronix

Hi everybody, I want to bulk send emails to many (around 300-600) mails using laravel scheduler, for this purpose I created a command to run along with laravel's task scheduler.

As for my mail API, I'm using laravel's integratin of the Mailgun API, Mailgun lets you send thoushands of them.

I also want to run the mail sending through a queue, afaik using a queue is specially for performance heavy tasks such as sending mail.

As for my questions, is this a good, performant way to send multiple mails with laravel scheduler?

Will each of my mails be properly sent to the queue for dispatching?

When I run php artisan schedule:run òn my local dev machine (Windws) I get the following message:

C:\xampp\htdocs\>php artisan schedule:run
Running scheduled command: "C:\xampp\php\php.exe" "artisan" App\Console\SendWeeklyMail1 > "NUL" 2>&1

But nothing happens after that, I haven't received any emails.

My command for sending mails:

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Mail;
use App\Models\Event;
use App\Models\Discount;
use App\Models\General;
use App\Models\Sub;
use App\Mail\weekly\WeeklyMail1;

class SendWeeklyMail1 extends Command

    protected $signature = 'emails:weekly';
    protected $description = "What's new this week? send weekly emails to subbed users";

    public function __construct()

    public function handle()

        $emails = [ '[email protected]', '[email protected]', '[email protected]', 
        '[email protected]', '[email protected]', '[email protected]',
        '[email protected]', '[email protected]', '[email protected]',
        '[email protected]', '[email protected]', '[email protected]', 
        '[email protected]', '[email protected]', '[email protected]', 
        '[email protected]', '[email protected]', '[email protected]' ];

        $mailData = [
            'subject' => 'Últimas novedades en '.env('APP_NAME'),
            'events' => $events,
            'discounts' => $discounts,

        foreach ($emails as $email)
            Mail::to( $email )->queue(new WeeklyMail1($mailData));


Kernel file:

protected $commands = [

    protected function schedule(Schedule $schedule)

Please sign in or create an account to participate in this conversation.