/** * Send the given notification. * * @param mixed $notifiable * @param \Illuminate\Notifications\Notification $notification * @return void */ public function send($notifiable, Notification $notification) { if (!$notifiable->routeNotificationFor('mail')) { return; } $message = $notification->toMail($notifiable); if ($message instanceof Mailable) { return $message->send($this->mailer); } $this->mailer->send($message->view, $message->data(), function ($m) use($notifiable, $notification, $message) { $recipients = empty($message->to) ? $notifiable->routeNotificationFor('mail') : $message->to; if (!empty($message->from)) { $m->from($message->from[0], isset($message->from[1]) ? $message->from[1] : null); } if (is_array($recipients)) { $m->bcc($recipients); } else { $m->to($recipients); } $m->subject($message->subject ?: Str::title(Str::snake(class_basename($notification), ' '))); foreach ($message->attachments as $attachment) { $m->attach($attachment['file'], $attachment['options']); } foreach ($message->rawAttachments as $attachment) { $m->attachData($attachment['data'], $attachment['name'], $attachment['options']); } }); }
/** * Send the given notification. * * @param mixed $notifiable * @param \Illuminate\Notifications\Notification $notification * @return void */ public function send($notifiable, Notification $notification) { if (!$notifiable->routeNotificationFor('mail')) { return; } $message = $notification->toMail($notifiable); $this->mailer->send($message->view, $message->toArray(), function ($m) use($notifiable, $notification, $message) { $m->to($notifiable->routeNotificationFor('mail')); $m->subject($message->subject ?: Str::title(Str::snake(class_basename($notification), ' '))); }); }
/** * Send the given notification. * * @param mixed $notifiable * @param \Illuminate\Notifications\Notification $notification * @return void */ public function send($notifiable, Notification $notification) { if (!$notifiable->routeNotificationFor('mail')) { return; } $message = $notification->toMail($notifiable); if ($message instanceof Mailable) { return $message->send($this->mailer); } $this->mailer->send($this->buildView($message), $message->data(), function ($mailMessage) use($notifiable, $notification, $message) { $this->buildMessage($mailMessage, $notifiable, $notification, $message); }); }