title: PHP open .msg file
body: <p>Some users are uploading .msg files to a folder.  I need to be able to open it up in a separate window or just open the original file.</p>
  
  <p>I can open everything that I allow, just not .msg files.</p>
  
  <p>Here is the code I'm using to display and download:</p>
  
  <pre><code>&lt;?php
    function listFolderFiles($dir){
      $ffs = scandir($dir);
  
      foreach($ffs as $ff){
        if($ff != '.' &amp;&amp; $ff != '..'){
          if(is_dir($dir.'/'.$ff)){
            // just displaying headers here
          }
          else{
            $filesize = filesize($dir . '/' . $ff);
            echo "&lt;a download href='$dir/$ff'&gt;$ff&lt;/a&gt;";
          }
        }
      }
      echo "&lt;br /&gt;";
   }
   listFolderFiles('files');
   ?&gt;
  </code></pre>
  
  <p>Not sure if I should post the code I use to upload, but I did include the .msg extension, and the user is indeed able to upload .msg files.</p>
  
  <p>I found this post:  <a href="https://stackoverflow.com/questions/16331169/display-msg-file-in-browser-using-php">display .msg file in browser using php</a></p>
  
  <p>And the answer there advised to use various HEADERS.  But I'm not sure why I should place the code for the headers.</p>