Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]OOP Klient poczty
Wolfie
post
Post #1





Grupa: Zarejestrowani
Postów: 686
Pomógł: 0
Dołączył: 10.11.2008
Skąd: Łódź

Ostrzeżenie: (20%)
X----


Witam

Szukam obiektowych skryptow napisanych najlepiej w php5 dotyczacych webowego klienta poczty.

Przegladalem wiele skryptow ale tam wszystko jest strukturalnie, lub mieszanina funkcji z logika prezentacji. A ze chce napisac wlasnego klienta poczty napisanego obiektowo potrzebne mi sa jakies przyklady i pomoce. Poniewaz moja nauka jezyka obiektowego dopiero sie rozpoczyna i nie potrafie przerobic od tak skryptu strukturalnego na obiektowy.

Jak narazie mam takie cos :

  1. <?
  2.  
  3. class Mailbox
  4.    {
  5.        protected $_connection = null;
  6.        
  7.        public function connect($server, $user, $pass, $port = 993, $protocol = 'imap')
  8.            {
  9.                if(!($this->_connection = imap_open('{imap.'.$server.':'.$port.'/'.$protocol.'/ssl}INBOX', $user, $pass)))
  10.                    throw new Exception ('Connection failure');
  11.            }
  12.            
  13.        public function inbox()
  14.            {
  15.                return $this->_sort = imap_sort($this->_connection, SORTARRIVAL, true);
  16.            }
  17.            
  18.        public function delete($mId);
  19.            {
  20.                return imap_delete($this->_connection, $mId);
  21.            }
  22.            
  23.        public function disconnect()
  24.            {
  25.                imap_expunge($this->_connection);
  26.                imap_close($this->_connection);
  27.            }
  28.        
  29.        public function show_headers()
  30.            {
  31.                return $this->_headers = imap_headers($this->_connection);
  32.            }
  33.            
  34.        public function body($mId)
  35.            {
  36.                return imap_fetchbody($this->_connection, $mId, 1);
  37.            }
  38.            
  39.        public function header($mID, $param = '' )
  40.            {
  41.                $eHeader = imap_header($this->_connection, $mId);
  42.            if($param)
  43.                return $eHeader->$param;
  44.                
  45.            return $eHeader;
  46.            }
  47.            
  48.        public function to($mId)
  49.            {
  50.                return $this->header($mId, 'toaddress');
  51.            }
  52.        
  53.        public function subject($mId)
  54.            {
  55.                return $this->header($mId, 'subject');
  56.            }
  57.        
  58.        public function from($mId)
  59.            {
  60.                return $this->header($mId, 'senderaddress');
  61.            }
  62.    
  63.    }
  64.    
  65.  
  66.    
  67. $mailbox = new Mailbox;
  68. $mailbox->connect('gmail.com','jakismail@gmail.com','jakieshaslo','993','imap');
  69. $tab = $mailbox->inbox();
  70. foreach($tab as $wart)
  71.    echo $wart.'<br />';
  72.    
  73. $header = $mailbox->show_headers();
  74.  
  75.                echo "<h1>Headers in INBOX</h1>\n";
  76.                //$this->_headers = imap_headers($this->_connection);
  77.                
  78.                if ($header == false)
  79.                    {
  80.                    echo "Call failed<br />\n";
  81.                    }
  82.                else
  83.                    {
  84.                    foreach ($header as $val)
  85.                        {
  86.                        echo $val . "<br />\n";
  87.                        }
  88.                    }
  89. mailbox->show_headers();    
  90. ?>


Ale nie mam zielonego pojecia jak np teraz dodac do tego logowanie uzytkownika lub zaznaczac maile np do wyrzucenia....

Ten post edytował Wolfie 15.02.2009, 21:21:35
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 26.09.2025 - 17:07