SSilence / php-imap-client

a easy solution for simple IMAP email access in php
MIT License
269 stars 136 forks source link

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

Open abdullahseba opened 7 years ago

abdullahseba commented 7 years ago

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.

mattparksjr commented 7 years ago

This has not been added. Let me mark it!

sergey144010 commented 7 years ago

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');
abdullahseba commented 7 years ago

hmm.. will try that.

abdullahseba commented 7 years ago

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

sergey144010 commented 7 years ago

The following does not happen ?

# before
array = [
0 => you message here
1=> ...
2 => ...
];
# after
array = [
0 => ...
1=> ...
2 => you message here
];
abdullahseba commented 7 years ago

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.

sergey144010 commented 7 years ago

What it says in current folder:

var_dump( getBriefInfoMessages() );
abdullahseba commented 7 years ago

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

sergey144010 commented 7 years ago
var_dump( $imap->getBriefInfoMessages() );
abdullahseba commented 7 years ago

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

sergey144010 commented 7 years ago
      $imap = new ImapClient($mailbox, $username, $password, $encryption);
      var_dump( $imap->getBriefInfoMessages() );
abdullahseba commented 7 years ago

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

sergey144010 commented 7 years ago

You missed somewhere $imap->

abdullahseba commented 7 years ago

$hostname = '{mail.e17pumphouse.org.uk:993/imap/ssl/novalidate-cert}';
$username = 'admin@e17pumphouse.org.uk';
$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() );
sergey144010 commented 7 years ago
$hostname = '{mail.e17pumphouse.org.uk:993/imap/ssl/novalidate-cert}';
$username = 'admin@e17pumphouse.org.uk';
$password = 'pass';

$imap = new ImapClient($mailbox, $username, $password, $encryption);
var_dump( $imap->getBriefInfoMessages() );
abdullahseba commented 7 years ago

[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.
sergey144010 commented 7 years ago

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 = 'admin@e17pumphouse.org.uk';
$password = 'pass';

$imap = new ImapClient($mailbox, $username, $password, $encryption);
var_dump( $imap->getBriefInfoMessages() );
abdullahseba commented 7 years ago

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 service@paypal.co.uk 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 service@paypal.co.uk 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 service@paypal.co.uk Receipt for your PayPal p (63752 chars)" } [14]=> array(2) { ["id"]=> int(15) ["info"]=> string(83) " UF 15)17-Apr-2017 service@paypal.co.uk 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 service@paypal.co.uk 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)" } }
mattparksjr commented 7 years ago

Please wrap your var_dump in <pre> tags

mattparksjr commented 7 years ago

@abdullahseba is this still an active issue?

abdullahseba commented 7 years ago

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

abdullahseba commented 7 years ago

getMessagesOverview() has the same problem. image

abdullahseba commented 7 years ago

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

sergey144010 commented 7 years ago

On the frontend sorted try?

abdullahseba commented 7 years ago

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

mattparksjr commented 7 years ago

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

abdullahseba commented 7 years ago

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