Page 1 of 1

Mvc web-based mail client

Posted: Tue Feb 17, 2009 4:13 pm
by Wolfie
Hello

I am new in programing (especialy oop) and mvc pattern.

I want to implement simple mail client but I have some dificulties
Maybe I will post here what I have already done and maybe u can tell me what I should do next.

First of all I have developed this class :

Code: Select all

 
<?
 
class MailboxAccess
    {
        protected $_connection = null;
        
        public function connect($server, $user, $pass, $port = 993, $protocol = 'imap')
            {
                if(!($this->_connection = imap_open('{imap.'.$server.':'.$port.'/'.$protocol.'/ssl}INBOX', $user, $pass)))
                    throw new Exception ('Connection failure');
            }
            
        public function inbox()
            {
                return $this->_sort = imap_sort($this->_connection, SORTARRIVAL, true);
            }
        /*  
        public function delete($mId);
            {
                return imap_delete($this->_connection, $mId);
            }
            */
        public function disconnect()
            {
                imap_expunge($this->_connection);
                imap_close($this->_connection);
            }
        
        public function show_headers()
            {
                return $this->_headers = imap_headers($this->_connection);
            }
            
        public function body($mId)
            {
                return imap_fetchbody($this->_connection, $mId, 1);
            }
            
        public function header($mID, $param = '' )
            {
                $eHeader = imap_header($this->_connection, $mId);
            if($param)
                return $eHeader->$param;
                
            return $eHeader;
            }
            
        public function status()
            {
                return imap_mailboxmsginfo($this->_connection);
            }
            
        public function to($mId)
            {
                return $this->header($mId, 'toaddress');
            }
        
        public function subject($mId)
            {
                return $this->header($mId, 'subject');
            }
        
        public function from($mId)
            {
                return $this->header($mId, 'senderaddress');
            }
    }
 
Than I did some login form but there is no sense to put it here.
Next I did this file :

Code: Select all

 
<?
 
include('../classes/Mailbox.php');
 
if(isset($_POST['send']))
    {
    $email = $_POST['email'];
    $pass = $_POST['pass'];
    
    $mailbox = new MailboxAccess;
    $mailbox->connect('gmail.com',$email,$pass,'993','imap');
    $tab = $mailbox->inbox();
    foreach($tab as $wart)
    echo $wart.'<br />';
    }
else
echo 'ERROR !!!';   
?>
 
This supose to be controller but unfortunately it have presentation logic here.

And this is all what I have done. Here I get stuck.
I do not know what should I do next , that's why I need help.