_protocol->status($count, $null); return $count; } /** * get a list of messages with number and size * * @param int number of message * @return int|array size of given message of list with all messages as array(num => size) */ public function getSize($id = 0) { $id = $id ? $id : null; return $this->_protocol->getList($id); } /** * * get a message with headers and body * * @param int number of message * @return Zend_Mail_Message */ public function getMessage($id) { // TODO: error handling! $message = $this->_protocol->retrive($id); return new Zend_Mail_Message($message); } /** * * get a message with only header and $bodyLines lines of body * * @param int number of message * @param int also retrieve this number of body lines * @return Zend_Mail_Message */ public function getHeader($id, $bodyLines = 0) { // TODO: error handling! $message = $this->_protocol->top($id, $bodyLines, true); if($bodyLines) { return new Zend_Mail_Message($message); } else { return new Zend_Mail_Message('', $message); } } /** * * create instance with parameters * Supported paramters are * - host hostname or ip address of POP3 server * - user username * - password password for user 'username' [optional, default = ''] * - port port for POP3 server [optional, default = 110] * * @params array mail reader specific parameters * @throws Zend_Mail_Exception */ public function __construct($params) { if(!isset($params['host']) || !isset($params['user'])) { Zend::loadClass('Zend_Mail_Read_Autodetect'); $settings = isset($params['auto']) ? $params['auto'] : (isset($this->auto) ? $this->auto : Zend_Mail_Read_Autodetect::TRY_ALL); $params = Zend_Mail_Read_Autodetect::findPop3($settings, get_class($this)); } $params['password'] = isset($params['password']) ? $params['password'] : ''; $params['port'] = isset($params['port']) ? $params['port'] : 110; $this->_protocol = new Zend_Mail_Read_Procotol_Pop3(); if(!$this->_protocol->connect($params['host'], $params['port'])) { throw new Zend_Mail_Exception('cannot connect to pop3 server'); } if(!$this->_protocol->login($params['user'], $params['password'])) { throw new Zend_Mail_exception('cannot login to pop3 server'); } } /** * * Close resource for mail lib. If you need to control, when the resource * is closed. Otherwise the destructor would call this. * */ public function close() { $this->_protocol->logout(); } /** * * Keep the server busy. * */ public function noop() { return $this->_protocol->noop(); } /* public function removeMessage() { return false; // TODO: tbd } */ /** * * Special handling for hasTop. The headers of the first message is * retrieved if Top wasn't needed/tried yet. * * @see Zend_Mail_Read_Abstract:__get() */ public function __get($var) { if(strtolower($var) == 'hastop') { if($this->_protocol->$hasTop === null) { // need to make a real call, because not all server are honest in their capas $this->_protocol->top(1, 0, false); } return $this->_protocol->$hasTop; } parent::__get($var); } } ?>