/** * @test */ public function it_gets_all_messages_and_sets_them_as_read() { $imap = $this->getImap(); /** @noinspection PhpUndefinedMethodInspection */ $imap->shouldReceive('sort')->with('ALL', SORTDATE, true, 0)->andReturn([1, 2]); $mailboxManager = new ImapMailboxService($imap); $this->assertEquals([1, 2], $mailboxManager->getAllMessages(SORTDATE, true, false)); }
$imap = ImapFactory::create($folder); $mailboxService = new ImapMailboxService($imap); //$messageNumbers = $mailboxService->getMessagesBetween('2016-01-17','2016-01-18'); $folders = ImapFolderCollectionFactory::create($mailboxService->getAllFolders()); // Uses getMailbox() method from the ImapConnection helper trait, or you can do: $imap->getConnection()->getMailbox()->getFolder(); $currentFolder = $mailboxService->getMailbox()->getFolder(); $aliases = $mailboxService->getAliases(); $isTrash = false; if (isset($aliases['trash'])) { if ($aliases['trash'] == $currentFolder) { $isTrash = true; } } // Show all messages for the trash folder, as these are usually auto deleted at specified time periods. So there shouldn't be too many! if ($isTrash) { $messageNumbers = $mailboxService->getAllMessages(); } else { $messageNumbers = $mailboxService->getMessagesAfter(time()); } $messages = ImapMessageCollectionFactory::create($messageNumbers, $imap); ?> <html> <head> <title>Emails</title> <script src="https://code.jquery.com/jquery-1.12.0.min.js"></script> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"> <!-- Optional theme -->