Ejemplo n.º 1
0
set_time_limit(0);
$time_start = microtime(true);
use Humps\ImapCacheManager\Helpers\Sorter;
use Humps\ImapCacheManager\ImapMessageCache;
use Humps\ImapCacheManager\Memcache\MemcacheFolderCache;
use Humps\ImapCacheManager\Memcache\MemcacheMessageCache;
use Humps\ImapCacheManager\Memcache\MemcacheServer;
use Humps\MailManager\Factories\ImapFactory;
use Humps\MailManager\ImapMailboxService;
require_once '../vendor/autoload.php';
$cacheServer = MemcacheServer::connect('localhost', 11211);
$messageCache = new MemcacheMessageCache($cacheServer);
$folderCache = new MemcacheFolderCache($cacheServer);
$folder = isset($_REQUEST['folder']) ? $_REQUEST['folder'] : 'INBOX';
try {
    $imap = ImapFactory::create($folder);
} catch (Exception $e) {
    die('Unable to connect to mail server');
}
$mailboxService = new ImapMailboxService($imap);
$folders = $folderCache->getAllCached();
Sorter::sort($folders, 'name');
// 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;
    }
}
Ejemplo n.º 2
0
<?php

use Humps\MailManager\Factories\ImapFactory;
use Humps\MailManager\ImapMailboxService;
require_once '../vendor/autoload.php';
$folder = isset($_REQUEST['folder']) ? $_REQUEST['folder'] : 'INBOX';
$imap = ImapFactory::create();
$mailboxService = new ImapMailboxService($imap);
$mailboxService->emptyTrash();
$message = "Trash Successfully Emptied";
header('Location:index.php?folder=' . $folder . '&success=' . $message);
Ejemplo n.º 3
0
		.message {
			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>
Ejemplo n.º 4
0
<?php

/**
 * This script can be used either via an ajax call to update cached folders and/or as a cron
 * job or scheduled task. It simply caches all folders returned from the server.
 */
use Humps\ImapCacheManager\Memcache\MemcacheFolderCache;
use Humps\ImapCacheManager\Memcache\MemcacheServer;
use Humps\MailManager\Factories\ImapFactory;
use Humps\MailManager\Factories\ImapFolderCollectionFactory;
use Humps\MailManager\ImapMailboxService;
set_time_limit(0);
require_once '../../vendor/autoload.php';
// The memcache server host
const HOST = 'localhost';
// The memcache server port
const PORT = 11211;
$cacheServer = MemcacheServer::connect(HOST, PORT);
$cache = new MemcacheFolderCache($cacheServer);
// Create the MailboxService so we can access our mailbox
$imap = ImapFactory::create('INBOX', '../imap_config/config.php');
$mailboxService = new ImapMailboxService($imap);
$folders = ImapFolderCollectionFactory::create($mailboxService->getAllFolders());
$cache->cacheFolders($folders);
Ejemplo n.º 5
0
set_time_limit(0);
require_once '../../vendor/autoload.php';
use Humps\ImapCacheManager\Memcache\MemcacheMessageCache;
use Humps\ImapCacheManager\Memcache\MemcacheServer;
use Humps\ImapCacheManager\ImapMessageCache;
use Humps\MailManager\Factories\ImapFactory;
use Humps\MailManager\ImapMailboxService;
// The number of days the message should remain cached for (Max: 30). Use 0 for never expires
const CACHE_DURATION = 28;
// The memcache server host
const HOST = 'localhost';
// The memcache server port
const PORT = 11211;
// Pass the cacheBody parameter as false if you do not want to cache the message body.
$cacheBody = isset($_REQUEST['cacheBody']) ? $_REQUEST['cacheBody'] : true;
$folder = isset($_REQUEST['folder']) ? $_REQUEST['folder'] : 'INBOX';
// Create the MailboxService so we can access our mailbox
$imap = ImapFactory::create($folder, '../imap_config/config.php');
$mailboxService = new ImapMailboxService($imap);
// Create the cache service
$cacheServer = MemcacheServer::connect(HOST, PORT);
$cache = new MemcacheMessageCache($cacheServer);
$messageCache = new ImapMessageCache($cache, $imap);
// Get messages after the last time a message was cached (this is a timestamp, which ImapMailboxService will handle)
$lastCached = $cacheServer->getLastCached() ? $cacheServer->getLastCached() : time() - 60 * 60 * 24;
echo $lastCached;
$messages = $mailboxService->getMessagesAfter($lastCached);
// Convert the CACHE_DURATION to seconds.
$expires = 60 * 60 * 24 * CACHE_DURATION;
// Now cache the messages
$messageCache->cacheMessages($messages, true, $expires);