How to cc to send mail in laravel
In Laravel, you can use the Mail
facade to send emails using the cc
method. Here's an example:
use Illuminate\Support\Facades\Mail;
Mail::to('[email protected]')
->cc('[email protected]')
->send(new MyMail());
In this example, the email will be sent to [email protected]
and a copy will be sent to [email protected]
.
You can also use the cc
method to send emails to multiple recipients:
Mail::to('[email protected]', '[email protected]')
->cc('[email protected]')
->send(new MyMail());
If you want to send emails using a specific mail driver, you can specify it using the driver
method:
Mail::driver('smtp')
->to('[email protected]')
->cc('[email protected]')
->send(new MyMail());
You can also use the cc
method in a mail class:
namespace App\Mail;
use Illuminate\Mail\Mailable;
class MyMail extends Mailable
{
public function build()
{
return $this->to('[email protected]')
->cc('[email protected]');
}
}
In this example, the MyMail
class extends the Mailable
class and overrides the build
method to set the to
and cc
recipients.
You can then send the email using the Mail
facade:
Mail::send(new MyMail());
Note that you need to configure your mail settings in the config/mail.php
file to use the Mail
facade.