title: How to attach Mpdf output as email attachment with Codeigniter?
body: <p>In my controller generating pdf layout and then attaching it as Pdf and with a custom filename. Here is the code </p>
  
  <pre><code>$this-&gt;load-&gt;library('mpdf');
  $mpdf = new Mpdf('L', 'A4', 0, 'Trebuchet MS', 6, 6, 9, 9, 3, 3, 'L');
  ob_start();
  echo $this-&gt;generateFoodReport($inspectionId);
  $html = ob_get_contents();
  ob_end_clean();
  $mpdf-&gt;WriteHTML(utf8_encode($html));
  $content = chunk_split(base64_encode($mpdf-&gt;Output('', 'S')));
  $filename = "inspection-report.pdf";
  
  $this-&gt;load-&gt;library('email');
  $this-&gt;email-&gt;set_mailtype("html");
  $this-&gt;email-&gt;set_newline("\r\n");
  $this-&gt;email-&gt;from($fromMail, $fromName);
  $this-&gt;email-&gt;to($mailTo);
  $this-&gt;email-&gt;subject($subject);
  $this-&gt;email-&gt;attach($content):
  $this-&gt;email-&gt;send();
  </code></pre>
  
  <p>How to attach the file with email.</p>