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

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners