title: Email Problem while add attachment file
body: <p>I have problem while i try to send email with attachment file, i just get message with blank attachment, how i can fix it. Here is my code: </p>
  
  <pre><code>$html2pdf = new HTML2PDF("P","A4", "fr");
  $html2pdf-&gt;writeHTML($content, isset($_GET['vuehtml']));
  $to = "example@yahoo.com"; 
  $subject = "Voucher Mediskon";
  $random_hash = md5(date("r", time()));
  $headers = "From: Admin Mediskon&lt;admin@" . $domain . "&gt;\r\nReply-To: admin@" . $domain;
  $headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
  $attachment = chunk_split(base64_encode( $html2pdf-&gt;Output("", "S") ));
  ob_start();
  ?&gt;
  --PHP-mixed-&lt;?php echo $random_hash; ?&gt; 
  Content-Type: multipart/alternative; boundary="PHP-alt-&lt;?php echo $random_hash; ?&gt;"
  --PHP-alt-&lt;?php echo $random_hash; ?&gt; 
  Content-Type: text/plain; charset="iso-8859-1"
  Content-Transfer-Encoding: 7bit
  --PHP-alt-&lt;?php echo $random_hash; ?&gt; 
  Content-Type: text/html; charset="iso-8859-1"
  Content-Transfer-Encoding: 7bit
  
  &lt;h2&gt;Terimakasih telah membeli voucher kami. Mediskon&lt;/h2&gt;
  &lt;p&gt;Silakan &lt;b&gt;unduh ( download )&lt;/b&gt; voucher pada &lt;b&gt;attachment&lt;/b&gt; yang kami kirim.&lt;/p&gt;
  --PHP-alt-&lt;?php echo $random_hash; ?&gt;--
  --PHP-mixed-&lt;?php echo $random_hash; ?&gt; 
  Content-Type: application/pdf; name="voucher.pdf" 
  Content-Transfer-Encoding: base64 
  Content-Disposition: attachment 
  &lt;?php echo $attachment; ?&gt;
  --PHP-mixed-&lt;?php echo $random_hash; ?&gt;--
  &lt;?php 
  $message = ob_get_clean();
  $mail_sent = @mail( $to, $subject, $message, $headers );
  </code></pre>