/**
  * @test
  */
 public function it_creates_an_ImapMessageCollection_object()
 {
     $imap = m::mock('Humps\\MailManager\\Contracts\\Imap');
     $imap->shouldReceive('getMessageHeaders')->andReturn(ImapMailManagerTestHelper::getMessageHeaders());
     $imap->shouldReceive('fetchStructure')->andReturn(ImapMailManagerTestHelper::fetchStructure());
     $imap->shouldReceive('fetchBody')->andReturn(ImapMailManagerTestHelper::fetchBody());
     $messages = ImapMessageCollectionFactory::create([1, 2], $imap);
     $this->assertInstanceOf('Humps\\MailManager\\Collections\\ImapMessageCollection', $messages);
     $this->assertEquals(2, count($messages));
 }
Exemple #2
0
// 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 -->
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css"
		  integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">

	<!-- Latest compiled and minified JavaScript -->
 /**
  * Returns the ImapMessageCollection for the given message numbers
  * @param $messageNumbers
  * @param bool $excludeBody
  * @return ImapMessageCollection
  */
 protected function getMessageCollection($messageNumbers, $excludeBody = false)
 {
     return ImapMessageCollectionFactory::create($messageNumbers, $this->imap, $excludeBody);
 }