Webklex / laravel-imap

Laravel IMAP is an easy way to integrate both the native php-imap module and an extended custom imap protocol into your Laravel app.
https://www.php-imap.com
MIT License
629 stars 179 forks source link

Can't retrieve messages, always returns 0 #454

Closed DevHeaven closed 1 year ago

DevHeaven commented 1 year ago

Hello

No matter what I try , I always get a zero message count. I've tried the standard sample. I've tried $folder->query()->all()->count() , I've tried $folder->query()->all()->get()->first() I've tried with getSubject() in foreach .... nothing seems to work.

When I foreach trough folders and echo $folder->name , I get "INBOX" as result

ANy starter advise to get this going ? Much appreciated !!

Earl0fPudding commented 1 year ago

Same problem here. When I'm just doing a simple:

        $client->checkConnection();
        $folder = $client->getFolderByPath($path);
        $messages = $folder->messages()->all()->get();
        return var_dump($messages);

The result is the following:

object(Webklex\PHPIMAP\Support\MessageCollection)#314 (3) {
  ["items":protected]=>
  array(0) {
  }
  ["escapeWhenCastingToString":protected]=>
  bool(false)
  ["total":protected]=>
  int(5)
}

The "total" amount is correct, I have 5 mails in this folder. Although I don't get any info regarding the actual messages. I'm on Laravel 9 with the latest laravel-imap from composer, IMAP server is plain 'ol Dovecot, php8.1.

manraf commented 1 year ago

I seem to have the same issue created over at the php-imap repository: https://github.com/Webklex/php-imap/issues/341

Just leaving this here as reference if it gets resolved at one place or the other.

manraf commented 1 year ago

I am reposting my solution from the php-imap repository here as well, maybe it helps:

After diving into the libraries code myself I figured out the issue. In my configuration file, for some reason the sequence-option was set to \Webklex\PHPIMAP\IMAP::ST_MSGN instead of \Webklex\PHPIMAP\IMAP::ST_UID. After changing it, the MessageCollection contained the items as expected.

Earl0fPudding commented 1 year ago

Thanks for figuring it out, @manraf ! I'm not sure though if I will continue using this library. As you can see for yourself, the support is underwhelming - for two months we haven't got a single response in this issue from a maintainer and there are only like 10 open issues.

webdeal commented 1 year ago

I am reposting my solution from the php-imap repository here as well, maybe it helps:

After diving into the libraries code myself I figured out the issue. In my configuration file, for some reason the sequence-option was set to \Webklex\PHPIMAP\IMAP::ST_MSGN instead of \Webklex\PHPIMAP\IMAP::ST_UID. After changing it, the MessageCollection contained the items as expected.

Really big thanks! I had the same issue and it helped!

RaphaelBuffl commented 1 year ago

Big thanks @manraf. You really saved my day!