PDF as a mail app - Laravel
I want to create a PDF using the barryvdh / laravel-dompdf package and email it as an attachment.
Now I have the code:
$pdf = PDF::loadView('layouts.factuur', array('factuur' => $factuur));
Mail::queue('emails.factuur', array('factuur' => $factuur), function($message) use ($pdf)
{
$message->to(Input::get('email'), Input::get('naam'))->subject('Onderwerp');
$message->attach($pdf->output());
});
But now I am getting the following error:
Serialization of 'Closure' is not allowed
+3
source to share
1 answer
You can only send serializable entities to the queue. This includes Eloquent models, etc. But not a PDF viewer instance. Therefore, you will probably need to do the following:
Mail::queue('emails.factuur', array('factuur' => $factuur), function($message)
{
$pdf = PDF::loadView('layouts.factuur', array('factuur' => $factuur));
$message->to(Input::get('email'), Input::get('naam'))->subject('Onderwerp');
$message->attach($pdf->output());
});
+10
source to share