title: Mail Queue and DOMPDF job works perfectly on homestead, but not on my production server
body: <p>Latest 5.1 Laravel 5.1.27 
  Latest dompdf 0.6.2</p>
  
  <p>So i have an email, that attaches a generated PDF, that is queued.</p>
  
  <p>Tested on homestead, both manually with artisan:work and artisen:listen, it all works well, i receive the email perfectly with the attached PDF.</p>
  
  <p>Only in my production server, that has same parameters, at least for what i can see, doesnt work!!</p>
  
  <p>It all works if synchronously with Mail::send</p>
  
  <p>When updated to Mail:queue, i get the Job stuck, on production i have supervisor with artisan:listen --tries=10 and it gets failed, and moved to the failed_jobs table.</p>
  
  <p>Aah, mail::queue workes perfectly if without PDF attachment</p>
  
  <p>So i could nail it down to the exception thrown by DOMPDF, only in production and only in a queued job!</p>
  
  <pre><code>exception 'ErrorException' with message 'Undefined index: SCRIPT_FILENAME' in /home/myapp_name/vendor/dompdf/dompdf/include/stylesheet.cls.php:147
  </code></pre>
  
  <p>So this line on stylesheet.cls.php:147 is</p>
  
  <pre><code>list($this-&gt;_protocol, $this-&gt;_base_host, $this-&gt;_base_path) = explode_url($_SERVER["SCRIPT_FILENAME"]);
  </code></pre>
  
  <p>So all comes down to being on CLI (command line interface), that doesn't have this $_SERVER["SCRIPT_FILENAME"] defined!!</p>
  
  <p>All would make sense to go down this road, but why the heck does it work perfectly when job processed in homestead, also on CLI??</p>
  
  <p>Hope i make sense!!
  Code for the queue</p>
  
  <pre><code>$data = [bla bla bla]; // this $data is for the blade render, and is different from the one used in the Closure, for the PDF, i know =)
      Mail::queue('emails.default', $data , function($message) use ($destinatarios, $user_spo_full_name, $spare_part_order, $spare_parts_order_list)
      {
          $message-&gt;to($destinatarios);
          $message-&gt;subject('Spare Part Order Confirmation - Your ref: ' . $spare_part_order-&gt;client_reference );
  
          $data =
              [
                  'user_full_name' =&gt; $user_spo_full_name,
                  'spare_part_order' =&gt; $spare_part_order,
                  'spare_parts_order_list' =&gt; $spare_parts_order_list
              ];
          $pdf = PDF::loadView('spareparts.sparepartsorder.pdf.spare-part-order', compact('data'));
          $message-&gt;attachData($pdf-&gt;output(), 'SP_'.$spare_part_order-&gt;client_reference . '.pdf' );
  
      });
  </code></pre>
  
  <p>Thanks in advance for any help and happy new year all!!</p>