Skip to content

Cannot copy or move Message because uidnext is not in the $status array #570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
kylxbn opened this issue Apr 6, 2025 · 0 comments
Open
Labels

Comments

@kylxbn
Copy link

kylxbn commented Apr 6, 2025

Describe the bug
Cannot move or copy Message because if the $status does not contain a uidnext key, then the copy or move function just gives up. My server does not give a uidnext key in the status.

Used config

$client = $cm->make([
    'host' => $account->imap_host,
    'port' => $account->imap_port,
    'encryption' => Account::IMAP_ENCRYPTION_METHODS[$account->imap_encryption_method],
    'validate_cert' => $account->imap_certificate_validation,
    'username' => $account->imap_username,
    'password' => $account->imap_password,
    'protocol' => Account::IMAP_PROTOCOLS[$account->imap_protocol],
]);

Code to Reproduce
The troubling code section which produces the reported bug.

$cm = new ClientManager();

$client = $cm->make([
    'host' => $account->imap_host,
    'port' => $account->imap_port,
    'encryption' => Account::IMAP_ENCRYPTION_METHODS[$account->imap_encryption_method],
    'validate_cert' => $account->imap_certificate_validation,
    'username' => $account->imap_username,
    'password' => $account->imap_password,
    'protocol' => Account::IMAP_PROTOCOLS[$account->imap_protocol],
]);

$client->connect();

$folder = $client->getFolderByName('INBOX');
   
$processedFolder = 'INBOX' . ($folder->delimiter) . 'Processed';

$messages = $folder->messages()->all()->markAsRead()->get();

$message = $messages[0];
$message->move($processedFolder);

Expected behavior
Message is moved to "INBOX.Processed" folder.

Screenshots
The message remains in the "INBOX" folder, as shown from the webmail and from Thunderbird.

Server:

  • OS: Ubuntu 24.04.1
  • PHP: 8.3
  • Version: v6.1.0
  • Provider: Xserver

Additional context
Xserver does not give a "uidnext" parameter so I can't move or copy the message. Here's what Xserver gives me:

// $client->getConnection()->examineFolder('INBOX.Processed')->validatedData();
[
    "flags" => [
        [
            "\Draft",
            "\Answered",
            "\Flagged",
            "\Deleted",
            "\Seen",
            "\Recent",
        ],
    ],
    "exists" => 1,
    "recent" => 0,
    "uidvalidity" => 742015324,
]

Given this code from Message.php, then it is expected for the move process to fail if uidnext is missing.

$this->client->openFolder($folder_path);
$status = $this->client->getConnection()->examineFolder($folder_path)->validatedData();
if (isset($status["uidnext"])) {
    // actually move the message
}
return null;
@kylxbn kylxbn changed the title Cannot copy or move because uidnext is not in the $status array Cannot copy or move Message because uidnext is not in the $status array Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants