title: Cakephp send email with attachment sending as 0 byte
body: <p>I am dynamically generating pdf files using dompdf and attaching those to email and sending. But in mail always Im getting the attachment as 0 byte. I'am creating the files under cake's tmp folder and it is getting created successfully. Im using cakephp 2.x and sending mail using CakeEmail. dompdf folders are in plugin folder. I have given necessary permission to lib/fonts directory. The file is not sending as attachment immediately after the creation. Whether there will be any kind of locking/delay while using dompdf that is cakeemail could not able to get the contents of the file (but file exists) ?  </p>
  
  <pre><code>App::uses('CakePdf', 'CakePdf.Pdf');
  $CakePdf = new CakePdf();
  
  $orderDetails = array('1' =&gt; 'myproduct');
  $CakePdf-&gt;viewVars(compact('orderDetails'));      
  
  $CakePdf-&gt;template('view_ticket_pdf', 'default');
  $filename = TMP . $data['Billing']['order_id'] . '.pdf';
  $pdf = $CakePdf-&gt;output();
  $CakePdf-&gt;write( $filename);
  
  $email = new CakeEmail('smtp');
  $desc = $email-&gt;template('order_mail');
  $email-&gt;emailFormat('html');
  $email-&gt;from(array(ADMIN_EMAIL =&gt; 'Admin'));
  $email-&gt;to('user@gmail.com');
  $email-&gt;attachments(array($filename));
  $email-&gt;subject('Your order');
  $content = $email-&gt;send();
  </code></pre>
  
  <p>Im getting error as fread(): Length parameter must be greater than 0 in CakeEmail. Instead of pdf, if I create a sample text file, it is attaching and size will be greater than 0. I am using  github.com/ceeram/CakePdf plugin for pdf creation.</p>