/** * Special handling for hasTop and hasUniqueid. The headers of the first message is * retrieved if Top wasn't needed/tried yet. * * @see Zend_Mail_Storage_Abstract:__get() * @param string $var * @return string * @throws Zend_Mail_Storage_Exception */ public function __get($var) { $result = parent::__get($var); if ($result !== null) { return $result; } if (strtolower($var) == 'hastop') { if ($this->_protocol->hasTop === null) { // need to make a real call, because not all server are honest in their capas try { $this->_protocol->top(1, 0, false); } catch (Zend_Mail_Exception $e) { // ignoring error } } $this->_has['top'] = $this->_protocol->hasTop; return $this->_protocol->hasTop; } if (strtolower($var) == 'hasuniqueid') { $id = null; try { $id = $this->_protocol->uniqueid(1); } catch (Zend_Mail_Exception $e) { // ignoring error } $this->_has['uniqueid'] = $id ? true : false; return $this->_has['uniqueid']; } return $result; }
public function index() { $this->id = "content"; $this->template = "import/list.tpl"; $this->layout = "common/layout"; require_once 'Zend/Mail/Protocol/Imap.php'; require_once 'Zend/Mail/Protocol/Pop3.php'; $request = Registry::get('request'); $db = Registry::get('db'); $lang = Registry::get('language'); if ($this->request->post['type'] == 'pop3') { try { $conn = new Zend_Mail_Protocol_Pop3($this->request->post['server'], '110', false); } catch (Zend_Mail_Protocol_Exception $e) { print "<span class=\"text-error\">" . $this->request->post['server'] . ": " . $lang->data['text_connection_failed'] . "</span> "; } if ($conn) { $s = $conn->connect($this->request->post['server']); if ($s) { try { $conn->login($this->request->post['username'], $this->request->post['password']); print "<span class=\"text-success\">" . $lang->data['text_connection_ok'] . "</span> "; } catch (Zend_Mail_Protocol_Exception $e) { print "<span class=\"text-error\">" . $this->request->post['username'] . ": " . $lang->data['text_login_failed'] . "</span> "; } } } } else { if ($this->request->post['type'] == 'imap') { try { $conn = new Zend_Mail_Protocol_Imap($this->request->post['server'], '143', false); $login = $conn->login($this->request->post['username'], $this->request->post['password']); if ($login) { print "<span class=\"text-success\">" . $lang->data['text_connection_ok'] . "</span> "; } else { print "<span class=\"text-error\">" . $this->request->post['username'] . ": " . $lang->data['text_login_failed'] . "</span> "; } } catch (Zend_Mail_Protocol_Exception $e) { print "<span class=\"text-error\">" . $this->request->post['server'] . ": " . $lang->data['text_connection_failed'] . "</span> "; } } else { print "<span class=\"text-error\">" . $lang->data['text_error'] . "</span> "; } } }
/** * Special handling for hasTop. The headers of the first message is * retrieved if Top wasn't needed/tried yet. * * @see Zend_Mail_Storage_Abstract:__get() * @param string $var * @return string * @throws Zend_Mail_Storage_Exception */ 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 try { $this->_protocol->top(1, 0, false); } catch (Zend_Mail_Exception $e) { // ignoring error } } return $this->_protocol->hasTop; } return parent::__get($var); }
public function testReadAfterClose() { $protocol = new Zend_Mail_Protocol_Pop3($this->_params['host']); $protocol->logout(); try { $protocol->readResponse(); } catch (Exception $e) { return; // test ok } $this->fail('no exception while reading from closed socket'); }
public function testServerUidl() { $mail = new Zend_Mail_Protocol_Pop3($this->_params['host']); $mail->login($this->_params['user'], $this->_params['password']); $uids = $mail->uniqueid(); $this->assertEquals(count($uids), 5); $this->assertEquals($uids[1], $mail->uniqueid(1)); }
private function checkLoginAgainstPOP3($username = '', $password = '') { $rc = 0; $emails = array($username); try { $conn = new Zend_Mail_Protocol_Pop3(POP3_HOST, POP3_PORT, POP3_SSL); if ($conn) { $s = $conn->connect(POP3_HOST); if ($s) { try { $conn->login($username, $password); $extra_emails = $this->model_user_user->get_email_addresses_from_groups($emails); $emails = array_merge($emails, $extra_emails); $this->add_session_vars($username, $username, $emails, 0); $rc = 1; } catch (Zend_Mail_Protocol_Exception $e) { } } } } catch (Zend_Mail_Protocol_Exception $e) { } return $rc; }