A notification is one event that via() routes to channels: mail, database and broadcast built in, Slack 353 (laravel/slack-notification-channel), Vonage 12,290 SMS (laravel/vonage-notification-channel) and community channels. make:notification creates the class, and any model using Notifiable, here Customer, receives it. Its via() returns ['mail', 'database']:
public function toMail(object $notifiable): MailMessage
{
return (new MailMessage)
->subject("Order #{$this->order->id} is now {$this->order->status}")
->greeting("Hi {$notifiable->name},")
->line("Your order status changed to {$this->order->status}.")
->action('View your order', route('orders.show', $this->order));
}$customer->notify(new OrderStatusChanged($order)) delivered the mail to Mailpit beside the order mail from Writing Mailables:
$ curl -s http://127.0.0.1:8017/api/v1/messages | jq -c '.messages[] | [.Subject, .To[0].Address]' ["Order #3 is now shipped","chen@example.com"] ["Order #1 has shipped","ana@example.com"]
MailMessage fills Laravel 2,157 's notification layout, so no template is needed. Notification::route('mail', 'ops@example.com') reaches an address with no model behind it.