php-imap-client icon indicating copy to clipboard operation
php-imap-client copied to clipboard

$imap->getMessages() not sorting by date.

Open abdullahseba opened this issue 8 years ago • 27 comments

Hi I had an email which was in my junk folder and it was not junk so I took it out into the inbox. The email is about a week old but $imap->getMessages() puts it on top (with the correct date stamp). Is this an issue or is it outlook? Thanks.

abdullahseba avatar Apr 19 '17 16:04 abdullahseba

This has not been added. Let me mark it!

mattparksjr avatar Apr 19 '17 16:04 mattparksjr

You mean

var_dump($imap->getMessages());

and

array = [
0 => you message here
];

You can use

# @param string $order        ASC or DESC
getMessages($number = 0, $start = 0, $order = 'DESC');

sergey144010 avatar Apr 19 '17 20:04 sergey144010

hmm.. will try that.

abdullahseba avatar Apr 20 '17 00:04 abdullahseba

I tried $emails = $imap->getMessages($number = 0, $start = 0, $order = 'DESC'); but it does nothing.

abdullahseba avatar Apr 20 '17 06:04 abdullahseba

The following does not happen ?

# before
array = [
0 => you message here
1=> ...
2 => ...
];
# after
array = [
0 => ...
1=> ...
2 => you message here
];

sergey144010 avatar Apr 20 '17 10:04 sergey144010

I did but its not in the date order of the mail. image So that's the correct order that the mail got in the inbox but not the correct date arrangement. Cuz "Don't stop now, you're halfway there" was originally in junk. But it should be ninth in the list which it is in office.

abdullahseba avatar Apr 20 '17 15:04 abdullahseba

What it says in current folder:

var_dump( getBriefInfoMessages() );

sergey144010 avatar Apr 20 '17 16:04 sergey144010

Fatal error: Uncaught Error: Call to undefined function getBriefInfoMessages()

abdullahseba avatar Apr 20 '17 17:04 abdullahseba

var_dump( $imap->getBriefInfoMessages() );

sergey144010 avatar Apr 20 '17 17:04 sergey144010

Fatal error: Uncaught Error: Call to undefined function getBriefInfoMessages()

abdullahseba avatar Apr 20 '17 18:04 abdullahseba

      $imap = new ImapClient($mailbox, $username, $password, $encryption);
      var_dump( $imap->getBriefInfoMessages() );

sergey144010 avatar Apr 20 '17 18:04 sergey144010

Fatal error: Uncaught Error: Call to undefined function getBriefInfoMessages() Cant do any more. All my code is from the docs.

abdullahseba avatar Apr 20 '17 18:04 abdullahseba

You missed somewhere $imap->

sergey144010 avatar Apr 20 '17 18:04 sergey144010

$hostname = '{mail.e17pumphouse.org.uk:993/imap/ssl/novalidate-cert}';
$username = '[email protected]';
$password = 'pass';

$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
$imap = new ImapClient($mailbox, $username, $password, $encryption);
var_dump( $imap->getBriefInfoMessages() );

abdullahseba avatar Apr 20 '17 18:04 abdullahseba

$hostname = '{mail.e17pumphouse.org.uk:993/imap/ssl/novalidate-cert}';
$username = '[email protected]';
$password = 'pass';

$imap = new ImapClient($mailbox, $username, $password, $encryption);
var_dump( $imap->getBriefInfoMessages() );

sergey144010 avatar Apr 20 '17 19:04 sergey144010

[20-Apr-2017 23:37:08 Europe/London] Slim Application Error:
Type: ArgumentCountError
Message: Too few arguments to function SSilence\ImapClient\ImapClient::getMessage(), 0 passed in C:\xampp\htdocs\uf4.0.8\app\sprinkles\webmail\src\Controller\WebmailController.php on line 38 and at least 1 expected
File: C:\xampp\htdocs\uf4.0.8\app\vendor\ssilence\php-imap-client\ImapClient\ImapClient.php
Line: 665
Trace: #0 C:\xampp\htdocs\uf4.0.8\app\sprinkles\webmail\src\Controller\WebmailController.php(38): SSilence\ImapClient\ImapClient->getMessage()
#1 [internal function]: UserFrosting\Sprinkle\Webmail\Controller\WebmailController->messagesGetList(Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#2 C:\xampp\htdocs\uf4.0.8\app\vendor\slim\slim\Slim\Handlers\Strategies\RequestResponse.php(41): call_user_func(Array, Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#3 C:\xampp\htdocs\uf4.0.8\app\vendor\slim\slim\Slim\Route.php(344): Slim\Handlers\Strategies\RequestResponse->__invoke(Array, Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#4 C:\xampp\htdocs\uf4.0.8\app\sprinkles\account\src\Authenticate\AuthGuard.php(52): Slim\Route->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response))
#5 [internal function]: UserFrosting\Sprinkle\Account\Authenticate\AuthGuard->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\Route))
#6 C:\xampp\htdocs\uf4.0.8\app\vendor\slim\slim\Slim\DeferredCallable.php(43): call_user_func_array(Array, Array)
#7 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\Route))
#8 C:\xampp\htdocs\uf4.0.8\app\vendor\slim\slim\Slim\MiddlewareAwareTrait.php(73): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\Route))
#9 C:\xampp\htdocs\uf4.0.8\app\vendor\slim\slim\Slim\MiddlewareAwareTrait.php(122): Slim\Route->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))
#10 C:\xampp\htdocs\uf4.0.8\app\vendor\slim\slim\Slim\Route.php(316): Slim\Route->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))
#11 C:\xampp\htdocs\uf4.0.8\app\vendor\slim\slim\Slim\App.php(476): Slim\Route->run(Object(Slim\Http\Request), Object(Slim\Http\Response))
#12 C:\xampp\htdocs\uf4.0.8\app\vendor\slim\csrf\src\Guard.php(167): Slim\App->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response))
#13 [internal function]: Slim\Csrf\Guard->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\App))
#14 C:\xampp\htdocs\uf4.0.8\app\vendor\slim\slim\Slim\DeferredCallable.php(43): call_user_func_array(Object(Slim\Csrf\Guard), Array)
#15 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\App))
#16 C:\xampp\htdocs\uf4.0.8\app\vendor\slim\slim\Slim\MiddlewareAwareTrait.php(73): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\App))
#17 C:\xampp\htdocs\uf4.0.8\app\vendor\slim\slim\Slim\MiddlewareAwareTrait.php(122): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))
#18 C:\xampp\htdocs\uf4.0.8\app\vendor\slim\slim\Slim\App.php(370): Slim\App->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))
#19 C:\xampp\htdocs\uf4.0.8\app\vendor\slim\slim\Slim\App.php(295): Slim\App->process(Object(Slim\Http\Request), Object(Slim\Http\Response))
#20 C:\xampp\htdocs\uf4.0.8\public\index.php(57): Slim\App->run()
#21 {main}
View in rendered output by enabling the "displayErrorDetails" setting.

abdullahseba avatar Apr 20 '17 22:04 abdullahseba

You show me ImapClient::getMessage() error, but in the code above there is no such method. Again.

$hostname = '{mail.e17pumphouse.org.uk:993/imap/ssl/novalidate-cert}';
$username = '[email protected]';
$password = 'pass';

$imap = new ImapClient($mailbox, $username, $password, $encryption);
var_dump( $imap->getBriefInfoMessages() );

sergey144010 avatar Apr 21 '17 05:04 sergey144010

array(21) { [0]=> array(2) { ["id"]=> int(1) ["info"]=> string(83) " 1) 4-Apr-2017 Yammer Abdullah, welcome to the (87797 chars)" } [1]=> array(2) { ["id"]=> int(2) ["info"]=> string(83) " 2) 6-Apr-2017 Yammer Getting Started: Become m (83849 chars)" } [2]=> array(2) { ["id"]=> int(3) ["info"]=> string(83) " 3) 7-Apr-2017 Microsoft Online Ser Approved: Your request fo (55150 chars)" } [3]=> array(2) { ["id"]=> int(4) ["info"]=> string(83) " 4) 7-Apr-2017 [email protected] Verification code to rese (63142 chars)" } [4]=> array(2) { ["id"]=> int(5) ["info"]=> string(63) " 5) 7-Apr-2017 Abdullah Seba tewst (47181 chars)" } [5]=> array(2) { ["id"]=> int(6) ["info"]=> string(83) " 6) 7-Apr-2017 Microsoft Online Ser New or modified user acco (54968 chars)" } [6]=> array(2) { ["id"]=> int(7) ["info"]=> string(76) " 7) 9-Apr-2017 [email protected] You sent a payment (86600 chars)" } [7]=> array(2) { ["id"]=> int(8) ["info"]=> string(83) " 8)11-Apr-2017 Yammer Make sure you've got Yamm (84729 chars)" } [8]=> array(2) { ["id"]=> int(9) ["info"]=> string(83) " 9)16-Apr-2017 Microsoft Online Ser New or modified user acco (46536 chars)" } [9]=> array(2) { ["id"]=> int(10) ["info"]=> string(83) " 10)16-Apr-2017 Microsoft Online Ser New or modified user acco (46563 chars)" } [10]=> array(2) { ["id"]=> int(11) ["info"]=> string(83) " 11)16-Apr-2017 Microsoft Online Ser New or modified user acco (46622 chars)" } [11]=> array(2) { ["id"]=> int(12) ["info"]=> string(83) " 12)16-Apr-2017 Microsoft Online Ser New or modified user acco (46626 chars)" } [12]=> array(2) { ["id"]=> int(13) ["info"]=> string(67) " 13)16-Apr-2017 Abdullah Seba tryhfdgsh (47973 chars)" } [13]=> array(2) { ["id"]=> int(14) ["info"]=> string(83) " UF 14)17-Apr-2017 [email protected] Receipt for your PayPal p (63752 chars)" } [14]=> array(2) { ["id"]=> int(15) ["info"]=> string(83) " UF 15)17-Apr-2017 [email protected] You submitted an order am (62370 chars)" } [15]=> array(2) { ["id"]=> int(16) ["info"]=> string(83) " 16)11-Apr-2017 Seema at Technology Don't stop now, you're ha (72333 chars)" } [16]=> array(2) { ["id"]=> int(17) ["info"]=> string(63) " 17)20-Apr-2017 Abdullah Seba testo (48087 chars)" } [17]=> array(2) { ["id"]=> int(18) ["info"]=> string(83) " U 18)21-Apr-2017 [email protected] Confirm your debit or cre (59087 chars)" } [18]=> array(2) { ["id"]=> int(19) ["info"]=> string(83) " U 19)21-Apr-2017 Microsoft Online Ser Order confirmation: Thank (53981 chars)" } [19]=> array(2) { ["id"]=> int(20) ["info"]=> string(83) " U 20)21-Apr-2017 Microsoft Office 365 Get started with Office 3 (63461 chars)" } [20]=> array(2) { ["id"]=> int(21) ["info"]=> string(83) " U 21)22-Apr-2017 Microsoft Online Ser View your Office 365 Busi (48064 chars)" } }

abdullahseba avatar Apr 22 '17 10:04 abdullahseba

Please wrap your var_dump in <pre> tags

mattparksjr avatar Apr 24 '17 12:04 mattparksjr

@abdullahseba is this still an active issue?

mattparksjr avatar May 09 '17 17:05 mattparksjr

No I'm dead. Again I havent updated, so when its fixed let me know.

abdullahseba avatar May 09 '17 17:05 abdullahseba

getMessagesOverview() has the same problem. image

abdullahseba avatar May 26 '17 15:05 abdullahseba

I think this is related to IMAP and will have to be sorted by udate in php before returning.

abdullahseba avatar May 26 '17 15:05 abdullahseba

On the frontend sorted try?

sergey144010 avatar May 26 '17 15:05 sergey144010

I will do for now, probably using Tablesorter. But ideally it should be done in php.

abdullahseba avatar May 26 '17 15:05 abdullahseba

I agree. +1. I'll work on this later

mattparksjr avatar May 26 '17 16:05 mattparksjr

While you about it, let us choose which way it does it 😉 getMessagesOverview("1:5", ascending)

abdullahseba avatar May 26 '17 17:05 abdullahseba