This example is made on how to add cc in laravel mail. if you want to see an example of how to add bcc in laravel mail then I will help you from this tutorial. you can understand the concept of how to add more cc in email. Here from this example, will learn laravel mail send multiple cc. Here, I will create a basic example of laravel mail send multiple bcc.

You can use this code with laravel 6, laravel 7, laravel 8 and laravel 9 versions. If you want to add cc or bcc recipient emails in laravel mail then just follow this tutorial. Laravel Mail provides cc() and bcc() methods to send more recipient emails for sending emails. So let's see the following example of sending laravel mail with cc and bcc.

laravel-9-send-mail-with-cc-and-bcc

You need to update the following controller code to send a mail with cc and bcc:

app/Http/Controllers/MailController.php

<?php

namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
use Mail;
use App\Mail\DemoMail;
  
class MailController extends Controller
{
    /**
     * Write code on Method
     *
     * @return response()
     */
    public function index()
    {
        $mailData = [
            'title' => 'Mail from laravelia.com',
            'body' => 'This is for testing email using smtp.'
        ];
  
        $ccEmails = ["demo@gmail.com", "demo2@gmail.com"];
        $bccEmails = ["demo3@gmail.com", "demo4@gmail.com"];
         
        Mail::to('your_email@gmail.com')
                ->cc($ccEmails)
                ->bcc($bccEmails)
                ->send(new DemoMail($mailData));
           
        dd("Email is sent successfully.");
    }
}

 

Read also: Laravel 9 CRUD Tutorial Example Using Eloquent ORM

 

Hope it can help you.

Category : #laravel

Tags : #laravel , #laravel mail