summaryrefslogtreecommitdiff
path: root/manager/application/controllers/MailController.php
blob: 5ee84d4514f651dabeeabf6113e667c7db00d582 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
 * @author markus
 * $Id: IndexController.php 6 2009-11-18 14:52:50Z markus $
 */

require_once(LIBRARY_PATH . '/imap/imapConnection.php');

class MailController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
    	$config = Zend_Registry::get('config');
		$imap_config = $config->imap;
        $imap = imapConnection::getInstance('cacert', $imap_config);
		$imap->imapSwitchMbox('INBOX');

        $ck = $imap->imapCheck();

        $headers = array();
        for ($i=0; $i < $ck->Nmsgs; $i++) {
        	$header = $imap->imapHeader($i+1);
        	$header->uid = $imap->imapUID($i+1);
        	$header->detailslink = $this->view->url(array('controller' => 'mail', 'action' => 'read', 'uid' => $header->uid), 'default', true);
        	$headers[] = $header;
        }

        $this->view->headers = $headers;
    }

    public function readAction()
    {
    	$config = Zend_Registry::get('config');
		$imap_config = $config->imap;
        $imap = imapConnection::getInstance('cacert', $imap_config);
		$imap->imapSwitchMbox('INBOX');

		$uid = $this->getRequest()->getParam('uid');

		$body = $imap->imapBodyByUID($uid);

		$this->view->mail_body = $body;
    }
}