border: 1px solid #ccc; border-top: 0; background: #fff; } .body { padding: 10px; } </style> </head> <body> <div class="message"> <?php if (!is_null($mid)) { $imap = Imap::create($currentFolder); $message = ImapMessage::create($mid, $imap); $messageService = new ImapMessageService($message, $imap); $messageService->downloadEmbeddedImages('images'); $mailboxService = new ImapMailboxService($imap); $folders = ImapFolderCollectionFactory::create($mailboxService->getAllFolders()); ?> <table class="table table-striped"> <tr> <td>From:</td> <td><?php echo htmlspecialchars($message->getFrom()->implodeEmails()); ?> </td> </tr> <tr> <td>To:</td>
/** * Gets the ImapMessage fro the given message * @param $messageNum * @param bool $excludeBody * @return mixed */ protected function getMessageFromServer($messageNum, $excludeBody = false) { return ImapMessageFactory::create($messageNum, $this->imap, $excludeBody); }
/** * Adds a message to the collection * @param Imap $imap * @param bool $excludeBody * @param bool $peek * @param string $outputEncoding * @param ImapMessageCollection $messages * @param Decoder $decoder * @param int $messageNum */ protected static function addImapMessage(Imap $imap, $excludeBody, $peek, $outputEncoding, ImapMessageCollection $messages, Decoder $decoder, $messageNum) { $messages->add(ImapMessageFactory::create($messageNum, $imap, $excludeBody, $peek, $decoder, $outputEncoding)); }
<?php use Humps\MailManager\Factories\ImapFactory; use Humps\MailManager\Factories\ImapMessageFactory; use Humps\MailManager\ImapMessageService; set_time_limit(0); require_once '../vendor/autoload.php'; $mid = $_REQUEST['mid']; $folder = $_REQUEST['folder']; $filename = $_REQUEST['filename']; $imap = ImapFactory::create($folder); $message = ImapMessageFactory::create($mid, $imap); $messageService = new ImapMessageService($message, $imap); if ($path = $messageService->downloadAttachmentByFilename($filename)) { // download to browser header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . $filename . '"'); readfile($path); $dir = dirname($path); unlink($path); rmdir($dir); rmdir($folder); }
/** * @test */ public function it_excludes_the_body_from_the_message() { /** * @var Imap $imap */ $imap = m::mock('Humps\\MailManager\\Contracts\\Imap'); $imap->shouldReceive('getMessageHeaders')->andReturn(ImapMailManagerTestHelper::getMessageHeaders()); $imap->shouldReceive('fetchStructure')->andReturn(ImapMailManagerTestHelper::fetchStructure()); $message = ImapMessageFactory::create(1, $imap, true); $imap->shouldNotHaveReceived('fetchBody'); $this->assertNull($message->getTextBody()); $this->assertNull($message->getHtmlBody()); }