title: Sending Email with attachment in html format
body: <p>I have PHP code that sends email with attachment but what I want is to put all the data like Full Name, Contact Number, etc into a table. I tried using <code>&lt;table&gt;</code> but the email is still a plain text. Can someone help me how to make it?</p>
  
  <p>This is my php code:</p>
  
  <pre><code>&lt;?php
   $cname = $_POST['Name'];
   $cnumber = $_POST['Tel'];
   $cemail = $_POST['emailadd'];
   $cmess = $_POST['contactmess'];
   $index = 'index.php';
  
   move_uploaded_file($_FILES["attachment"]["tmp_name"] , "/files/upload/" .  $_FILES["attachment"]["name"]);
  
   $to = 'peace@gmail.com'; 
   $subject = 'Careers Inquiry';  
   $random_hash = md5(date('r', time())); 
   $headers = "From: ". $cemail ."\r\nReply-To:". $cemail; 
   $headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
   $headers .= "Content-Type: text/html; charset='iso-8859-1'";
   $attachment = chunk_split(base64_encode(file_get_contents("/files/upload/" .$_FILES["attachment"]["name"]))); 
  
   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;html&gt;
  &lt;body&gt;
      &lt;table&gt;
          &lt;tr&gt;&lt;td&gt;Name: &lt;/td&gt;&lt;td&gt;&lt;?php echo $cname; ?&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;Contact Number: &lt;/td&gt;&lt;td&gt;&lt;?php echo $cnumber; ?&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;Email Address: &lt;/td&gt;&lt;td&gt;&lt;?php echo $cemail; ?&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;Message: &lt;/td&gt;&lt;td&gt;&lt;?php echo $cmess; ?&gt;&lt;/td&gt;&lt;/tr&gt;
      &lt;/table&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  --PHP-alt-`&lt;?php echo $random_hash; ?&gt;`-- 
  
  --PHP-mixed-`&lt;?php echo $random_hash; ?&gt;`  
  Content-Type: application/octet-stream; name="`&lt;?php echo $_FILES["attachment"]["name"];?&gt;`"  
  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 ); 
  unlink('/files/upload/' . $_FILES["attachment"]["name"]);
  echo $mail_sent ? header('Location: '. $index): '&lt;script type="text/javascript"&gt;       alert("Sorry, service temporary unavailable."); &lt;/script&gt;'; 
  ?&gt;
  </code></pre>