How to cc another mail in mailer in laravelk
In Laravel, you can CC another email address in a mailer by using the cc
method when sending an email. Here's an example:
// Send an email with CC
Mail::to('[email protected]')
->cc('[email protected]')
->send(new MyEmail());
In this example, MyEmail
is a mailer class that extends Illuminate\Mail\Mailable
. The cc
method is used to specify the email address to CC.
You can also use the cc
method in the to
method:
// Send an email with CC
Mail::to('[email protected]', 'Recipient Name')
->cc('[email protected]', 'CC Name')
->send(new MyEmail());
In this example, you can also specify the name of the recipient and the CC recipient.
If you want to CC multiple email addresses, you can use an array:
// Send an email with CC
Mail::to('[email protected]')
->cc(['[email protected]', '[email protected]'])
->send(new MyEmail());
You can also use the cc
method in the to
method with an array:
// Send an email with CC
Mail::to(['[email protected]', '[email protected]'], ['Recipient 1', 'Recipient 2'])
->cc(['[email protected]', '[email protected]'], ['CC 1', 'CC 2'])
->send(new MyEmail());
In this example, you can specify multiple recipients and CC recipients with their names.