How to set CC And BCC Email Address In Laravel Mail?

By Hardik Savani October 19, 2022 Category : Laravel

Hey Folks,

This example is focused on how to add cc in laravel mail. if you want to see an example of how to add bcc in laravel mail then you are in the right place. you can understand a concept of how to add more cc in email. Here you will learn laravel mail send multiple cc. Here, Create a basic example of laravel mail send multiple bcc.

You can use these tips 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 it's very easy. Laravel Mail provides cc() and bcc() method to send more recipient emails for sending emails. so let's see the following solution.

Send Email Code:

You can follow the below tutorial to sending email from laravel. Then the below code i will show you how to send cc and bcc emails.

Follow Mail Sending Tutorial: Laravel Mail | Laravel Send Email Tutorial

.

Send Email with cc and bcc:

You need to update the following controller code:

app/Http/Controllers/MailController.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 ItSolutionStuff.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.");

}

}

Now, you can check and you will find the following result:

I hope it can help you...

Tags :