Compose and send emails with Mailables
Laravel Mail provides a clean API for composing and sending emails through various drivers like SMTP, Mailgun, and SES.
A Mailable bundles the envelope (to, subject), content (view, data), and attachments into one class.
OrderShipped
extends Mailable
Envelope
subject, from, replyTo
Content
Blade view + data
Attachments
files, PDFs
PHP
class OrderShipped extends Mailable {
public function __construct(
public Order $order
) {}
public function envelope(): Envelope {
return new Envelope(
subject: 'Order Shipped',
);
}
public function content(): Content {
return new Content(
view: 'mail.order-shipped',
);
}
public function attachments(): array {
return [
Attachment::fromPath('/path/to/receipt.pdf'),
];
}
}