/** * 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] * - ssl 'SSL' or 'TLS' for secure sockets * * @param $params array mail reader specific parameters * @throws Zend_Mail_Storage_Exception * @throws Zend_Mail_Protocol_Exception */ public function __construct($params) { if (is_array($params)) { $params = (object) $params; } $this->_has['fetchPart'] = false; $this->_has['top'] = null; $this->_has['uniqueid'] = null; if ($params instanceof Zend_Mail_Protocol_Pop3) { $this->_protocol = $params; return; } if (!isset($params->user)) { /** * @see Zend_Mail_Storage_Exception */ require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('need at least user in params'); } $host = isset($params->host) ? $params->host : 'localhost'; $password = isset($params->password) ? $params->password : ''; $port = isset($params->port) ? $params->port : null; $ssl = isset($params->ssl) ? $params->ssl : false; $this->_protocol = new Zend_Mail_Protocol_Pop3(); $this->_protocol->connect($host, $port, $ssl); $this->_protocol->login($params->user, $password); }
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> "; } } }
/** * 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] * - ssl 'SSL' or 'TLS' for secure sockets * * @param $params array mail reader specific parameters * @throws Zend_Mail_Storage_Exception * @throws Zend_Mail_Protocol_Exception */ public function __construct($params) { $this->_has['fetchPart'] = false; if ($params instanceof Zend_Mail_Protocol_Pop3) { $this->_protocol = $params; return; } if (!isset($params['user'])) { throw new Zend_Mail_Storage_Exception('need at least user in params'); } $params['host'] = isset($params['host']) ? $params['host'] : 'localhost'; $params['password'] = isset($params['password']) ? $params['password'] : ''; $params['port'] = isset($params['port']) ? $params['port'] : null; $params['ssl'] = isset($params['ssl']) ? $params['ssl'] : false; $this->_protocol = new Zend_Mail_Protocol_Pop3(); $this->_protocol->connect($params['host'], $params['port'], $params['ssl']); $this->_protocol->login($params['user'], $params['password']); }
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), 7); $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; }