title: PDF as mail attachment - Laravel
body: <p>I want to create a PDF using the barryvdh/laravel-dompdf package and send this with an email as attachment.</p>
  
  <p>The code I have now is:</p>
  
  <pre><code>$pdf = PDF::loadView('layouts.factuur', array('factuur' =&gt; $factuur));
  
  Mail::queue('emails.factuur', array('factuur' =&gt; $factuur), function($message) use ($pdf)
     {
         $message-&gt;to(Input::get('email'), Input::get('naam'))-&gt;subject('Onderwerp');
         $message-&gt;attach($pdf-&gt;output());
      });
  </code></pre>
  
  <p>But now I get the following error:</p>
  
  <pre><code>Serialization of 'Closure' is not allowed
  </code></pre>