Closed
Description
Laravel Version
10.48.12
PHP Version
8.2.19
Database Driver & Version
No response
Description
Sending a mailable with a large disk attachment results in an out of memory exception. This is because the whole file is loaded into memory at
framework/src/Illuminate/Mail/Mailable.php
Line 494 in 97238d2
It should be sent to Symfony mailer as a stream, which is already supported
framework/src/Illuminate/Mail/Message.php
Line 320 in 97238d2
Steps To Reproduce
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
*/
public function attachments(): array
{
return [
Attachment::fromStorage('/path/to/large.pdf')
->as('large.pdf')
->withMime('application/pdf'),
];
}
https://laravel.com/docs/11.x/mail#attaching-files-from-disk