1. Go to this page and download the library: Download mnapoli/imapi library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$ids = $client->getEmailIds();
foreach ($ids as $id) {
if (/* this email needs to be synced */) {
$email = $client->getEmailFromId($id);
// ...
}
}
// Read from the `INBOX.Sent` folder
$query = QueryBuilder::create('INBOX.Sent')
->youngerThan(3600) // 1 hour
->flagSeen(true) // return messages with \\seen flag set, or false for messages with seen flag off.
// more options are flagAnswered(boolean), flagDeleted(boolean),flagDraft(boolean),flagFlaged(boolean),flagRecent(boolean)
->getQuery();
$emails = $client->getEmails($query);
$folders = $client->getFolders();
$emailIds = ['123', '456'];
// Moving from the INBOX to the Archive folder
$client->moveEmails($emailIds, 'INBOX', 'Archive');