public function __construct($options) { $params = $this->convertParams($options); $class = $params['protocol_class']; $this->protocol = new $class($params['host'], $params['port'], $params['ssl']); $this->protocol->login($params['user'], $params['password']); $class = $params['storage_class']; $this->storage = new $class($this->protocol); }
/** * 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 Protocol\Pop3) { $this->_protocol = $params; return; } if (!isset($params->user)) { throw new Exception\InvalidArgumentException('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 Protocol\Pop3(); $this->_protocol->connect($host, $port, $ssl); $this->_protocol->login($params->user, $password); }
public function testServerUidl() { $mail = new 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)); }