title: How to send email with pdf attachment using php?
body: <p>Hi i am trying to send a mail with doc, docx and pdf attachment. i am getting email with doc and docx. but when i try to send mail with pdf attachment is it not working. Thus i am getting the error message 'The uploaded file is not supported file type'. I cannt find the error. Can anyone help me? My Code: </p>
  
  <pre><code>&lt;?php 
      $to = $_POST["txtTo"];
      $subject = $_POST["txtSubject"];
      $from = $_POST["txtFormEmail"];
      $message = $_POST["txtDescription"];
      $random_hash = md5(date('r', time()));
      $headers .= "From: ".$from."&lt;".$from."&gt;\nReply-To: ".$_POST["txtFormEmail"]."";
      $headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
      $strFilesName = $_FILES["fileAttach"]["name"];
      $attachment = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"])));
      ob_start();
      //Turn on output buffering 
      ?&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;?php  echo $message; ?&gt; --PHP-alt-&lt;?php  echo $random_hash; ?&gt;-- --PHP-mixed-&lt;?php  echo $random_hash; ?&gt; Content-Type: &lt;?php  echo $_FILES["fileAttach"]["type"]; ?&gt;; name="&lt;?php  echo $strFilesName; ?&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();
  
      if ($_FILES["fileAttach"]["type"] == "application/pdf"|| $_FILES["fileAttach"]["type"]=="application/msword"||$_FILES["fileAttach"]["type"]==application/vnd.openxmlformats-officedocument.wordprocessingml.document")if($_FILES["fileAttach"]["size"] &lt; 1024000){if ($_FILES["fileAttach"]["error"] &gt; 0){ echo "Error:
      " . $_FILES["fileAttach"]["error"]."&lt;br /&gt;";}else{$mail_sent = @mail( $to, $subject, $message, $headers );
  }
  
  echo $mail_sent ? "Mail sent" : "Mail failed";}else{echo ' File Size should be with in 1000 KB';} }else{echo 'The uploaded file is not supported file type.'; }?&gt;
  </code></pre>