barbushin / php-imap

Manage mailboxes, filter/get/delete emails in PHP (supports IMAP/POP3/NNTP)
MIT License
1.65k stars 459 forks source link

imap_fetchheader(): UID does not exist #717

Open SkylineGTRS opened 8 months ago

SkylineGTRS commented 8 months ago

Environment (please complete the following information):

Describe the bug Unable to fetch mails $mailbox->getMail($$mailId, false);

The used code:

$mailbox = new Mailbox(
            config('imap.dec_host') . 'INBOX', // IMAP server and mailbox folder
            config('imap.dec_username'), // Username for the before configured mailbox
            config('imap.dec_password'), // Password for the before configured username
            null, // Directory, where attachments will be saved (optional)
            'UTF-8', // Server encoding (optional)
            true, // Trim leading/ending whitespaces of IMAP path (optional)
            false, // Attachment filename mode (optional; false = random filename; true = original filename)
        );

        // set some connection arguments (if appropriate)
        $mailbox->setConnectionArgs(CL_EXPUNGE);

        try {
            $mailsIds = $mailbox->searchMailbox('UNSEEN');

            if (count($mailsIds)) {
                foreach ($mailsIds as $id) {
                    $mail = $mailbox->getMail($id, false);
                }
            }
        } catch (Throwable $ex) {
            report($ex);
        }

Additional context Composer is up to date and all required php extensions are installed.

What could be causing this issue? any ideas?

trittler commented 1 month ago

@SkylineGTRS same Problem here. Still trying to find out what the problem is. Suddenly did not work anymore with the error message: "imap_fetchheader(): UID does not exist"

trittler commented 1 month ago

@SkylineGTRS I solved the problem in my project. I did not select the correct folder using switchMailbox($folder).