PHP script running on text console (CLI) copying and dumping IMAP mailboxes.
Script should work in 3 ways:
1. Copying mails and mailbox structure from source IMAP account to mboxes in local folder (dumping, archiveing)
2. Copying mails and mailbox structure from local folder mboxes to target IMAP account
3. Both together: copying from source to target and dumping at the same time.
Main rules:
1. Source IMAP mailbox cannot be changed in any way. Read-only.
2. All flags at target mailbox (read, deleted, and so on) should be the same as at source mailbox after procedure.
3. All mail dates should be kept as well.
4. SSL should be an option (gmail accounts)
5. Configuration for IMAP accounts should be read from xml or txt external file.
6. Whole structure (directories and subdirectories and...) should be read and write. No changes. Everything retained.
7. After running a script target directory should look 100% like source directory so there is need to delete emails form target direcotry before copying.
8. I need verbose version - any signs of running like "INBOX mailbox is copying" and "." for each email at console is necessary.
9. I need an option to copy whole mailbox from source direcotry to an folder in target mailbox retaining the whole structure. In that case source INBOX goes to archive/INBOX and so on. Name of this folder is read form config file (in the previous example - archive). If this name is empty - we copy to main folder it means just to the target mailbox.
I will give access to shell on my ubuntu server to test it. I also give access to 3 mailboxes (one will be gmail) to test it.