title: imap_search() for unseen messages does not returning anything
body: <p>I am currently trying to get the UNSEEN/UNREAD messages from my server. Currently, I have this:</p>
  
  <pre><code>$openmail = imap_open($dns, $email, $password) or die("Cannot Connect " . imap_last_error());
  if ($openmail) {
      /* grab emails */
      $emails = imap_search($openmail, 'UNSEEN');
      if ($emails) {
          //For every e-mail.
          $tot = imap_num_msg($openmail);
          for ($i = $tot; $i &gt; 0; $i--) {
              $structure = imap_fetchstructure($openmail, $i);
              if (isset($structure-&gt;parts) &amp;&amp; is_array($structure-&gt;parts) &amp;&amp; isset($structure-&gt;parts[1])) {
                  $part = $structure-&gt;parts[1];
                  $message = imap_fetchbody($openmail, $i, 2, FT_PEEK);
  
                  if ($part-&gt;encoding == 3) {
                      $message = imap_base64($message);
                  } else if ($part-&gt;encoding == 1) {
                      $message = imap_8bit($message);
                  } else {
                      $message = imap_qprint($message);
                  }
              }
              $header = imap_header($openmail, $i);
              $from = imap_utf8($header-&gt;fromaddress);
              $subject = $header-&gt;Subject;
              $subject = substr($subject, 0, 150);
              $date = $header-&gt;Date;
          }
          /* Print out the Unseen messages in here! */
      } else {
          /* No unseen messages */
          echo "No unseen";
      }
  }
  </code></pre>
  
  <p>I've tried sending multiply emails to my mailserver, refreshed the page with the above script. But I keep getting the "No unseen". </p>
  
  <p>I've tried to output the <code>$emails</code> but it's empty. It can't find anything.</p>
  
  <p>If I try to just get ALL the messages (no unseen filter), I can see the emails I've sent to the mailbox, although, they're all marked as read.</p>