title: PHP IMAP sync a folder
body: <p>I am building the PHP application to sync IMAP mailbox with local copy.
  I need to find a way to load only messages from IMAP folders that i didn't load yet.</p>
  
  <p>PHP IMAP library has the function imap_search to do something similar.
  For example, imap_search($conn, 'SINCE "8 August 2012"', SE_UID);</p>
  
  <p>However, this solution doesn't work well. Often emails have wrong date (can be future date) and sync works wrong.</p>
  
  <p>What is the best practice to do sync with IMAP server from PHP? How to load real list of messages i didn't load yet?
  For now i can see only one way to do this - loads IDs fo all emails on IMAP server and compare with list if IDs saved locally.
  Is there better way? Thanks.</p>