title: Error 324 (net::ERR_EMPTY_RESPONSE): Unknown error
body: <p>I get the following error in Chrome every time I try to run my script on a Linux server: Error 324 (net::ERR_EMPTY_RESPONSE): Unknown error. In Firefox it just shows a blank white page. </p>
  
  <p>Whenever I run it on my local test server (IIS on Windows 7) it runs exactly the way it should with no errors. I am pretty sure that it is a problem with the imap_open function.</p>
  
  <pre><code>&lt;?php 
  
  error_reporting(E_ALL);
  echo "test";
  // enter gmail username below e.g.--&gt; $m_username = "yourusername";
  $m_username = "username";
  
  // enter gmail password below e.g.--&gt; $m_password = "yourpword";
  $m_password = "password";
  
  // Enter the mail server to connect to
  $server = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX';
  
  // enter the number of unread messages you want to display from mailbox or 
  //enter 0 to display all unread messages e.g.--&gt; $m_acs = 0; 
  $m_acs = 10; 
  
  // How far back in time do you want to search for unread messages - one month = 0 , two weeks = 1, one week = 2, three days = 3,
  // one day = 4, six hours = 5 or one hour = 6 e.g.--&gt; $m_t = 6;
  $m_t = 2;
  
  //-----------&gt;Nothing More to edit below
  //open mailbox
  $m_mail = imap_open ($server, $m_username . "@gmail.com", $m_password)
  
  // or throw an error
  or die("ERROR: " . imap_last_error());
  
  // unix time gone by
  $m_gunixtp = array(2592000, 1209600, 604800, 259200, 86400, 21600, 3600);
  
  // Date to start search
  $m_gdmy = date('d-M-Y', time() - $m_gunixtp[$m_t]); 
  
  //search mailbox for unread messages since $m_t date 
  $m_search=imap_search ($m_mail, 'ALL');
  
  
  
  // Order results starting from newest message
  rsort($m_search);
  
  //if m_acs &gt; 0 then limit results
  if($m_acs &gt; 0){ 
  array_splice($m_search, $m_acs);
  } 
  
  $read = $_GET[read];
  if ($read) {
     function get_mime_type(&amp;$structure) {
     $primary_mime_type = array("TEXT", "MULTIPART","MESSAGE", "APPLICATION", "AUDIO","IMAGE", "VIDEO", "OTHER");
     if($structure-&gt;subtype) {
      return $primary_mime_type[(int) $structure-&gt;type] . '/' .$structure-&gt;subtype;
     }
      return "TEXT/PLAIN";
     }
     function get_part($stream, $msg_number, $mime_type, $structure = false,$part_number    = false) {
  
      if(!$structure) {
          $structure = imap_fetchstructure($stream, $msg_number);
      }
      if($structure) {
          if($mime_type == get_mime_type($structure)) {
              if(!$part_number) {
                  $part_number = "1";
              }
              $text = imap_fetchbody($stream, $msg_number, $part_number);
              if($structure-&gt;encoding == 3) {
                  return imap_base64($text);
              } else if($structure-&gt;encoding == 4) {
                  return imap_qprint($text);
              } else {
              return $text;
          }
      }
  
          if($structure-&gt;type == 1) /* multipart */ {
          while(list($index, $sub_structure) = each($structure-&gt;parts)) {
              if($part_number) {
                  $prefix = $part_number . '.';
              }
              $data = get_part($stream, $msg_number, $mime_type, $sub_structure,$prefix .    ($index + 1));
              if($data) {
                  return $data;
              }
          } // END OF WHILE
          } // END OF MULTIPART
      } // END OF STRUTURE
      return false;
     } // END OF FUNCTION
  
        // GET TEXT BODY
     $dataTxt = get_part($m_mail, $read, "TEXT/PLAIN");
  
     // GET HTML BODY
     $dataHtml = get_part($m_mail, $read, "TEXT/HTML");
  
     if ($dataHtml != "") {
         $msgBody = $dataHtml;
      $mailformat = "html";
     } else {
      $msgBody = ereg_replace("\n","&lt;br&gt;",$dataTxt);
      $mailformat = "text";
     }
  
        if ($mailformat == "text") {
      echo "&lt;html&gt;&lt;head&gt;&lt;title&gt;Messagebody&lt;/title&gt;&lt;/head&gt;&lt;body    bgcolor=\"white\"&gt;$msgBody&lt;/body&gt;&lt;/html&gt;";
     } else {
      echo $msgBody; // It contains all HTML HEADER tags so we don't have to make them.
     }
     exit;
  }
  
  //loop it 
  foreach ($m_search as $what_ever) { 
  
  //get imap header info for obj thang 
  $obj_thang = imap_headerinfo($m_mail, $what_ever);
  
  //get body info for obj thang 
  $obj_thangs = imap_body($m_mail, $what_ever);
  
  //Then spit it out below.........if you dont swallow 
  echo "&lt;div align=center&gt;&lt;br /&gt;&lt;font face=Arial size=2 color=#800000&gt;Message ID# " . $what_ever . "&lt;/font&gt;
  
  &lt;table bgcolor=#D3D3D3 width=700 border=1 bordercolor=#000000 cellpadding=0 cellspacing=0&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;table width=100% border=0&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;table width=100% border=0&gt;
  &lt;tr&gt;
  &lt;td bgcolor=#F8F8FF&gt;&lt;font face=Arial size=2 color=#800000&gt;Date:&lt;/font&gt; &lt;font face=Arial size=2 color=#000000&gt;" . date("F j, Y, g:i a", $obj_thang-&gt;udate) . "&lt;/font&gt;&lt;/td&gt;
  &lt;td bgcolor=#F8F8FF&gt;&lt;font face=Arial size=2 color=#800000&gt;From:&lt;/font&gt; &lt;font face=Arial size=2 color=#000000&gt;" . $obj_thang-&gt;fromaddress . "&lt;/font&gt;&lt;/td&gt;
  &lt;td bgcolor=#F8F8FF&gt;&lt;font face=Arial size=2 color=#800000&gt;To:&lt;/font&gt; &lt;font face=Arial size=2 color=#000000&gt;" . $obj_thang-&gt;toaddress . " &lt;/font&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;/table&gt;
  &lt;/td&gt;
  &lt;/tr&gt;&lt;tr&gt;&lt;td bgcolor=#F8F8FF&gt;&lt;font face=Arial size=2 color=#800000&gt;Subject:&lt;/font&gt; &lt;font face=Arial size=2 color=#000000&gt;" . $obj_thang-&gt;Subject . "&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;
  &lt;/tr&gt;
  &lt;/table&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;/body&gt;";
  
  } echo "&lt;div align=center&gt;&lt;font face=Arial size=4 color=#800000&gt;&lt;b&gt;" . $m_empty . "&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;";
  //close mailbox
  imap_close($m_mail);
  ?&gt;
  </code></pre>