Laravel 9 has gained a https://laravel.com/docs/9.x/mail#attachable-objects. Using the Attachable interface, you can specify what should happen when an object gets used as an attachment.

Let's look at how you would attach files to Mailables in previous versions of Laravel. Imagine that your app has a simple Photo model with a path property that contains the path to the actual image file.

// in a Mailable public function __construct(public Photo $photo) { } public function build() { return $this ->view('emails.yourView') ->attach($this->photo->path); }
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners