php-imap
php-imap copied to clipboard
Get array of messages UID from specific folder
I keep copies of emails in the database, I periodically want to sync them with a mailbox. To avoid fetching large amounts of data having a list of message UIDs is convenient. Then I can add (with getMessageByUid($uid = $UID))/remove single messages in an easy and fast way.
I figure out that I can use this code to return only messages UIDs as an array:
$folder = $this->client->getFolder($remoteFolderName, "/");
$remoteUIDs = $folder->query()->getClient()->getConnection()->getUid();
I think that a built-in, more straightforward method will be useful. I'm also not 100% sure if my current solution doesn't have any drawbacks.