Background of the project :
I am working on a project which goal is to keep track of all emails received in a mailbox. The app connects to the mailbox and store every emails as files.
The user must have the possibility to use his mailbox regardless of the app behavior.
I am using the pop protocol at the moment i am writing this.
How it should work :
Let's say there are 10 unread mails in the mailbox, not stored by the app yet.
Case 1 : The user connects first : he reads, deletes others, tags them as spam or whatever : the app must still store each of the 10emails as files.
Case 2 : The app connects first, store the 10 emails and do something to never store them again, but the when the user will connect to his mailbox, he should still see the 10 emails as unread, and do whatever he wants with them.
How it works at the moment.. :
The function does retrieve every unread emails, and stores them as files (also downloads any attachments).
The first case works very well, i'm using outlook with my mailbox, and whatever i am doing with my emails, the app will still see the emails as unread, find them, and finally do the job.
The second case, however, seems to not work as intended : after storing the emails, i am using the imap_delete to mark these emails for deletion, and then, when everything is finished, i use imap_close with the CL_EXPUNGE flag to delete them, so that the app will not store them again next time...
The problem is that, this also deletes the emails from the server...meaning that in some cases, although the emails will have been stored, the user will never see them in his mailbox...
Question Time
Is there a way, in PHP, to delete emails only for my app, so it does not store the same emails several times, instead of deleting them from the server ? I know outlook makes it possible, because if not, it would not work in the first case either...
Is there any solution to this ? Is there a flag or a function that would do it correctly in php with the pop protocol ? Or is it possible using imap protocol and imap functions in php ?