I would like to create a php script to fetch the new emails using IMAP and store them in the my database. I want to know how can I identify the new emails which are arrived to the inbox and other mailboxes after the last sync.
The same IMAP email account is connected with outlook and therefore the new emails might have already been seen in the outlook, which might not sync to the PHP Application yet. I cannot use the UNSEEN flag because of the same mailbox is used in multiple places. I want to know which is the best way to the get the new emails by using the last email sync.
Say there is 100 emails in the inbox. my php program sync 50 on the last time. now it have to sync the next 50 emails only. But in those new 50 mails 25 emails are been checked using outlook (already seen). So when I use the UNSEEN flag criteria for the PHP application its only gives the 25 emails which are not read yet, but I should get the 50 emails.
I should be able to use something from the last email sync from PHP application to get the next set. But I don't know which one I should use.