title: Imap_fetch_overview and newest / oldest mail
body: <p>I am struggling with sequence for imap_fetch_overview. Is the mail 1 the oldest or newest mail? If a new mail arrives does it get a higher id or not?</p>
  
  <p>Solution:</p>
  
  <pre><code>   $check = imap_check($connection);
     $result = array();   
  
     if($check-&gt;Nmsgs &gt; 0){
  
          $sort = imap_sort($connection, SORTARRIVAL, 0);
  
          $msgs = '';
  
          $i = 1;
  
          foreach($sort as $id)
          {
              if($i &gt; 200) break;
              $msgs = $msgs . $id . ',';
              $i++;
          }
  
          $response = imap_fetch_overview($connection, rtrim($msgs,','));
          foreach ($response as $msg){
              $result[] = $msg;
          } 
      }
  </code></pre>