list mails, read mails

fix smaller issues in imap class
mail controller
list contents of mailbox
read mails
AddPoints
Markus Warg 14 years ago
parent ae053ad037
commit 2597013887

@ -16,9 +16,35 @@ class MailController extends Zend_Controller_Action
public function indexAction()
{
// action body
$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;
}
}

@ -3,5 +3,26 @@
* @author markus
* $Id: index.phtml 25 2009-12-02 15:43:21Z markus $
*/
$this->headLink()->appendStylesheet('/css/mail.css');
?>
<H1><?php print I18n::_('Mail'); ?></H1>
<table>
<tr>
<th><?php print I18n::_('From');?></th>
<th><?php print I18n::_('To');?></th>
<th><?php print I18n::_('Subject');?></th>
<th><?php print I18n::_('Date');?></th>
<th><?php print I18n::_('Size');?></th>
</tr>
<?php
foreach ($this->headers as $header) {
print " <tr>\n";
print " <td><a href=\"" . $header->detailslink . "\">" . $header->fromaddress . "</a></td>";
print " <td>" . $header->toaddress . "</td>";
print " <td>" . $header->subject . "</td>";
print " <td>" . $header->date . "</td>";
print " <td>" . $header->Size . "</td>";
print " </tr>\n";
}
?>
</table>

@ -0,0 +1,10 @@
<?php
/**
* @author markus
* $Id: index.phtml 25 2009-12-02 15:43:21Z markus $
*/
$this->headLink()->appendStylesheet('/css/mail.css');
?>
<H1><?php print I18n::_('Read Mail'); ?></H1>
<?php
print_r($this->mail_body);

@ -407,8 +407,8 @@ class imapConnection {
if ($ret === false) {
if ($reconnect === true) {
$this->imap = $this->imapOpen($this->server.$this->mbox,
$this->config->getValue('username'),
$this->config->getValue('password'),
$this->config->username,
$this->config->password,
OP_HALFOPEN);
$ret = imap_ping($this->imap);
@ -471,26 +471,26 @@ class imapConnection {
* @param $instanceName
* @param $config
*/
protected function __construct($instanceName,$config) {
protected function __construct($instanceName, $config) {
$this->instanceName = $instanceName;
$this->config = $config;
if (!$this->config->hasValue('mailhost')) {
if (!isset($this->config->mailhost)) {
throw new IMAPException(__METHOD__ . ' config attribute missing: "mailhost"');
}
if (!$this->config->hasValue('username')) {
if (!isset($this->config->username)) {
throw new IMAPException(__METHOD__ . ' config attribute missing: "username"');
}
if (!$this->config->hasValue('password')) {
if (!isset($this->config->password)) {
throw new IMAPException(__METHOD__ . ' config attribute missing: "password"');
}
if (!$this->config->hasValue('port')) {
if (!isset($this->config->port)) {
throw new IMAPException(__METHOD__ . ' config attribute missing: "port"');
}
$this->server = '{'.$this->config->getValue('mailhost').':'.$this->config->getValue('port').'/imap';
if( $this->config->hasValue('use_tls') &&
$this->config->getValue('use_tls') == true ) {
$this->server = '{'.$this->config->mailhost.':'.$this->config->port.'/imap';
if( isset($this->config->use_tls) &&
$this->config->use_tls != 0 ) {
$this->server .= '/tls';
}
$this->server .= '/novalidate-cert}';
@ -502,8 +502,8 @@ class imapConnection {
$this->imap = null;
$this->imap = $this->imapOpen($this->server.$mbox,
$this->config->getValue('username'),
$this->config->getValue('password'),
$this->config->username,
$this->config->password,
OP_HALFOPEN);
if ($this->imap === false) {
@ -535,9 +535,11 @@ class imapConnection {
return $instance;
}
/*
if (!$config instanceof Config) {
throw new IMAPException(__METHOD__ . ' no config');
}
*/
$object = new imapConnection($instanceName, $config);

@ -0,0 +1,25 @@
@CHARSET "UTF-8";
#content table {
border: 1px solid black;
border-collapse: collapse;
}
#content th {
border: 1px solid black;
padding: 3px;
}
#content td {
border: 1px solid black;
padding: 3px;
}
#content a {
text-decoration: none;
color: #000000;
}
#content a:hover {
color: #777777;
}
Loading…
Cancel
Save