php-imap
php-imap copied to clipboard
Ignore select folders with /noselect tag
Is your feature request related to a problem? Please describe.
Refers to - https://github.com/Webklex/php-imap/issues/266
Gmail (I don't know about the others yet) is one of the mail clients containing a special folder [Gmail] with the tag /Noselect. When calling the LoadStatus method, we try to select this folder, but since the special flag is not taken into account, getting the list of folders ends with a ResponceException
RFC 9051 7.3.1
\Noselect
It is not possible to use this name as a selectable mailbox.
If this folder cannot be selected, then accordingly it cannot contain child folders.
Describe the solution you'd like Not throw Exception and just silently skip this folder.
Describe alternatives you've considered
Client.php
public function isNotSelectable(array $flags)
{
return array_filter($flags, function ($item) {
return strtolower($item) === '\noselect';
});
}
and in getFoldersWithStatus method i solved like that
$items = $this->connection->folders('', $pattern)->validatedData();
if(!empty($items)){
foreach ($items as $folder_name => $item) {
if (!$this->isNotSelectable($item["flags"])) {
What do you think about this? I can make a PR.