예제 #1
0
			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>
				<td><?php 
 /**
  * @test
  */
 public function it_returns_false_when_the_part_does_not_exist()
 {
     $connection = $this->getImapConnectionMock();
     $imap = $this->getImapMock($connection);
     $message = $this->getMessageMock();
     $messageService = new ImapMessageService($message, $imap);
     /**
      * @var Attachment $attachment
      */
     $attachment1 = $this->getAttachment('apple.png', '2');
     $attachment2 = $this->getAttachment('orange.png', '2.1');
     $attachments = $attachment = m::mock('Humps\\MailManager\\Collections\\ImapAttachmentCollection');
     $attachments->shouldReceive('count')->andReturn(2);
     $message->shouldReceive('getAttachments')->andReturn($attachments);
     $iterator = new ArrayIterator([$attachment1, $attachment2]);
     $attachments->shouldReceive('getIterator')->andReturn($iterator);
     $path = $messageService->downloadAttachmentByPart('3', 'attachments');
     $this->assertFalse($path);
 }
예제 #3
0
<?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);
}