I'm sending notifications using the facade and it works well for addressing multiple 'to' emails however I need to be able to CC someone else in.
Notification::route('mail', ['[email protected]', '[email protected]'])->notify(new InvoicePaid($invoice));
I am hoping to address user1, and cc user2. Is it possible with the notification facade?
I suppose a solution (not as elegant as I would want), is to include the cc into the array that is passed and then define it in the MailMessage().
$data = array('name' => 'User Name', 'count' => 6, 'body' => 'My str', 'cc' = > '[email protected]');
On the Notification
public function toMail($notifiable)
{
$cc = $this->data['cc'];
return (new MailMessage)
->cc($cc)
You can pass the user to be cc-ed through the constructor. Let's call it $user2:
$user1->notify(new InvoicePaid($invoice, $user2));
In your notification:
public function __construct($invoice, User $user)
{
$this->user = $user;
}
public function toMail($notifiable)
{
return (new MailMessage)
->cc($this->user->email)
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With