Laravel - Mail - Attaching Files From Disk
If you have stored a file on one of your filesystem disks, you may attach it to the email using the attachFromStorage
method:
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->view('emails.orders.shipped')
->attachFromStorage('/path/to/file');
}
If necessary, you may specify the file's attachment name and additional options using the second and third arguments to the attachFromStorage
method:
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->view('emails.orders.shipped')
->attachFromStorage('/path/to/file', 'name.pdf', [
'mime' => 'application/pdf'
]);
}
The attachFromStorageDisk
method may be used if you need to specify a storage disk other than your default disk:
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->view('emails.orders.shipped')
->attachFromStorageDisk('s3', '/path/to/file');
}