How to add cc field in laravel mail

To add a CC field in Laravel mail, you can use the cc method when sending a mail using the Mail facade or the Illuminate\Support\Facades\Mail class.

Here is an example of how to do it:

use Illuminate\Support\Facades\Mail;

Mail::to('[email protected]')
    ->cc('[email protected]')
    ->send(new MyMail());

In this example, MyMail is a mail class that extends Illuminate\Mail\Mailable. You can define the CC field in the build method of your mail class:

namespace App\Mail;

use Illuminate\Mail\Mailable;

class MyMail extends Mailable
{
    public function build()
    {
        return $this->from('[email protected]')
            ->subject('Test Mail')
            ->cc('[email protected]');
    }
}

You can also use the cc method when sending a mail using the Mail facade:

Mail::send('emails.my-mail', [], function ($message) {
    $message->to('[email protected]')
        ->cc('[email protected]');
});

In this example, emails.my-mail is the view that will be used to render the mail. The second argument is an array of data that will be passed to the view. The third argument is a closure that allows you to configure the mail.

You can also use the cc method when sending a mail using the Illuminate\Support\Facades\Mail class:

$mail = (new MyMail())->onSend(function ($message) {
    $message->to('[email protected]')
        ->cc('[email protected]');
});
Mail::send($mail);

Make sure to replace MyMail with the actual name of your mail class.

You can also use the cc method when sending a mail using the Illuminate\Mail\Message class:

$message = new \Illuminate\Mail\Message();
$message->to('[email protected]')
    ->cc('[email protected]');
Mail::send($message);

Note that the cc method can be used multiple times to add multiple CC recipients.