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', ['user1@domain.com', 'user2@domain.com'])->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' = > 'user2@domain.com');
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)
...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.