How to Send Bulk Mail Using Queue in Laravel 9

Websolutionstuff | Mar-15-2022 | Categories : Laravel PHP

In this article, we will see how to send bulk mail using queue in laravel 9. Laravel queue is used for sending bulk mail with a background process, as we know if we are sending single mail laravel application it is working properly without taking more time but if you want to send multiple emails in laravel then it will take too much time and also you can not do any operation during this time periods.

So, let's see how to send bulk mail in laravel 9 using queue, laravel 9 send bulk mail using queue, how to send bulk mail in laravel 9, laravel 9 send email using queue

So, if you want to send bulk mail then you need to use the laravel queue using the queue we can send multiple emails in laravel with the background process. let's start and follow the below steps for how to send bulk mail in laravel 9.

Step 1 : Create Laravel 9 Application and Change In .env File

Step 2 : Create Route

Step 3 : Create Queue Table

Step 4 : Create Controller 

Step 5 : Create Job

Step  6 : Create Mail Blade


Step 1 : Change In .env File

First of we are creating the laravel 9 application and after that, we will set up mail configuration in the .env file as below. here we have used





 Step 2 : Create Route

In this step, we will create routes for sending bulk mail using the queue.

use App\Http\Controllers\SendMailController;

Route::get('send/mail', [SendMailController::class, 'send_mail'])->name('send_mail');


Step 3 : Create Queue Table

Now, we will create a 'jobs' table in the database. So, copy the below command and run it in your terminal.

php artisan queue:table

php artisan migrate‚Äč


Step 4 : Create Controller 

In this step, we will create SendMailController and add the below code.


namespace App\Http\Controllers;

use Illuminate\Http\Request;

class SendMailController extends Controller
    public function send_mail(Request $request)
    	$details = [
    		'subject' => 'Test Notification'
        $job = (new \App\Jobs\SendQueueEmail($details))

        echo "Mail send successfully !!";



Step 5 : Create Job

Now, we need to create the SendQueueEmail.php file in the app\Jobs folder using the below command in your terminal and copy the below code. 

php artisan make:job SendQueueEmail



namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use App\User;
use Mail;

class SendQueueEmail implements ShouldQueue
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    protected $details;
    public $timeout = 7200; // 2 hours

     * Create a new job instance.
     * @return void
    public function __construct($details)
        $this->details = $details;

     * Execute the job.
     * @return void
    public function handle()
        $data = User::all();
        $input['subject'] = $this->details['subject'];

        foreach ($data as $key => $value) {
            $input['email'] = $value->email;
            $input['name'] = $value->name;
            \Mail::send('mail.Test_mail', [], function($message) use($input){
                $message->to($input['email'], $input['name'])


Step  6 : Create Mail Blade

In this step, we will create a mail blade file in resources/views/mail/Test_mail.blade.php and write add below mail content.

Hi <br/>
This is Test Mail.<br />
Thank you !!

And run the below command in your terminal to send manually mail.

php artisan queue:listen



Output :



You might also like :

Recommended Post
Featured Post
How to Check User Browser is Supported or Not in jQuery
How to Check User Browser is S...

In this article, we will see how to check user browser is supported or not in jquery. Some time latest features are not...

Read More


How To File Upload Using Node.js
How To File Upload Using Node....

In this example, we will delve into the process of performing file uploads using Node.js. This tutorial will provide you...

Read More


How To Integrate Paypal Payment Gateway In Laravel
How To Integrate Paypal Paymen...

In this tutorial I will teach you the most important topic of how to integrate the PayPal payment gateway in larave...

Read More


How To Roll back Specific Migration In Laravel
How To Roll back Specific Migr...

In this article, we will explore the process of rolling back specific migrations in Laravel, focusing on Laravel version...

Read More