Here are the steps on how to set CC and BCC email addresses in Laravel Mail:
- Open your Laravel project’s
config/mail.php
file. - In the
mailers
array, find the mailer that you want to use to send the email. - Add the
cc
andbcc
keys to the mailer’s configuration. - The
cc
key should contain an array of email addresses that you want to CC. - The
bcc
key should contain an array of email addresses that you want to BCC.
For example, the following code will set the CC and BCC email addresses for the smtp
mailer:
PHP
'smtp' => [
'host' => 'smtp.gmail.com',
'port' => 465,
'username' => 'your_email@gmail.com',
'password' => 'your_password',
'encryption' => 'ssl',
'cc' => ['cc@example.com'],
'bcc' => ['bcc@example.com'],
],
Once you have set the CC and BCC email addresses, you can send an email using the Mail::send()
method. For example:
PHP
Mail::send('emails.welcome', ['name' => $user->name'], function ($message) {
$message->to($user->email);
$message->cc('cc@example.com');
$message->bcc('bcc@example.com');
});
This code will send an email to the user’s email address, with the CC and BCC addresses set to the specified email addresses.