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
641 stars 182 forks source link

search by date not working ( SINCE , On , Before ) #447

Closed olrtan closed 2 years ago

olrtan commented 2 years ago

Hi, Thank you for awesome library

i try to search by date but i get the same results 0

my code `$client = Client::account('another')->connect();

    $folder = $client->getFolderByName('INBOX');

    $query = $folder->query();

    $count = $query->all()->count();

    dump('all messages : ' . $count);

    $aMessage = $query->since('01.01.2022')->get();
    dump('Since 1 : ' . $aMessage->count());

    $aMessage = $query->since('21 Aug 2022')->get();
    dump('Since 2 : ' . $aMessage->count());

    $aMessage = $query->since('21.Aug.2022')->get();
    dump('Since 3 : ' . $aMessage->count());

    $aMessage = $query->since(\Carbon\Carbon::now()->subDays(30)->format('d M y'))->get();
    dump('Since 4: ' . $aMessage->count());

    $aMessage = $query->since(\Carbon\Carbon::now()->subDays(30)->format('d-M-Y'))->get();
    dump('Since 5: ' . $aMessage->count());

    $aMessage = $query->since(\Carbon\Carbon::now()->subDays(30)->format('d-M-y'))->get();
    dump('Since 6: ' . $aMessage->count());

    $aMessage = $query->since(\Carbon\Carbon::now()->subDays(30)->format('d.M.Y'))->get();
    dump('Since 7: ' . $aMessage->count());

    $aMessage = $query->since(\Carbon\Carbon::now()->subDays(30)->format('d.M.y'))->get();
    dump('Since 8: ' . $aMessage->count());

    $aMessage = $query->since(\Carbon\Carbon::now()->subDays(30))->get();
    dump('Since 9: ' . $aMessage->count());

    $aMessage = $query->where([["SINCE" => "21 Aug 2022"]])->get();
    dump('Since 10: ' . $aMessage->count());`

results :

"all messages : 22591" "Since 1 : 0" "Since 2 : 0" "Since 3 : 0" "Since 4: 0" "Since 5: 0" "Since 6: 0" "Since 7: 0" "Since 8: 0" "Since 9: 0" "Since 10: 0"

thanks

Webklex commented 2 years ago

Hi @olrtan , thanks for your report. It could be that your provider expects a different date format. You can change the format inside your config: https://github.com/Webklex/laravel-imap/blob/master/src/config/imap.php#L36

If you've published the config before, it should be located inside your config folder: config/imap.php

Best regards & happy coding,

Webklex commented 2 years ago

If you have any further questions, please head over to https://github.com/Webklex/php-imap

Best regards,