title: Email TCPDF Generated PDF file with php mail function
body: <p>PDF file is being generated by tcpdf library but I cant attach it to email. It sends Email with an empty 1kb PDF file.</p>
  
  <blockquote>
  <pre><code>$to = 'receiver@gmail.com';
  $subject = 'Receipt';
  $repEmail = 'info@gmail.com';
  
  $fileName = 'receipt.pdf';
  $fileatt = $pdf-&gt;Output($fileName, 'S');
  $attachment = chunk_split($fileatt);
  $eol = PHP_EOL;
  $separator = md5(time());
  
  $headers = 'From: Sender &lt;'.$repEmail.'&gt;'.$eol;
  $headers .= 'MIME-Version: 1.0' .$eol;
  $headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"";
  
  $message = "--".$separator.$eol;
  $message .= "Content-Transfer-Encoding: 7bit".$eol.$eol;
  $message .= "This is a MIME encoded message.".$eol;
  
  $message .= "--".$separator.$eol;
  $message .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
  $message .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
  
  $message .= "--".$separator.$eol;
  $message .= "Content-Type: application/pdf; name=\"".$fileName."\"".$eol; 
  $message .= "Content-Transfer-Encoding: base64".$eol;
  $message .= "Content-Disposition: attachment".$eol.$eol;
  $message .= $attachment.$eol;
  $message .= "--".$separator."--";
  
  if (mail($to, $subject, $message, $headers)){
  echo "Email sent";
  }
  
  else {
  echo "Email failed";
  }
  </code></pre>
  </blockquote>
  
  <p>I know its much easier with phpmailer but I'm required to do it with mail function and dont use any library.
  Any help is appreciated.</p>