/** * login to imap server * * @param object $_params * @return void * @throws Felamimail_Exception_IMAPInvalidCredentials * @throws Felamimail_Exception_IMAPServiceUnavailable */ public function connectAndLogin($_params) { $timeStartConnect = microtime(true); try { $this->_protocol->connect($_params->host, $_params->port, $_params->ssl); } catch (Exception $e) { throw new Felamimail_Exception_IMAPServiceUnavailable($e->getMessage()); } $timeEndConnect = microtime(true); $connectTime = $timeEndConnect - $timeStartConnect; try { //TODO: set at account config and use it here???? $imapConfig = Tinebase_Config::getInstance()->get(Tinebase_Config::IMAP); if (is_object($imapConfig) && $imapConfig->backend === 'cyrus' && isset($imapConfig->cyrus['useProxyAuth']) && $imapConfig->cyrus['useProxyAuth']) { $params = array('authzid' => $_params->user, 'authcid' => $imapConfig->cyrus['admin'], 'password' => $imapConfig->cyrus['password']); $loginResult = $this->_protocol->saslAuthenticate($params); } else { $loginResult = $this->_protocol->login($_params->user, $_params->password); } } catch (Exception $e) { throw new Felamimail_Exception_IMAPServiceUnavailable($e->getMessage()); } if (!$loginResult) { throw new Felamimail_Exception_IMAPInvalidCredentials('Cannot login, user or password wrong.'); } $timeEndLogin = microtime(true); $loginTime = $timeEndLogin - $timeEndConnect; if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' CONNECT TIME: ' . $connectTime . ' seconds'); } if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' LOGIN TIME: ' . $loginTime . ' seconds'); } }
/** * login to imap server * * @param object $_params * @return void * @throws Felamimail_Exception_IMAPInvalidCredentials, Felamimail_Exception_IMAPServiceUnavailable */ public function connectAndLogin($_params) { $timeStartConnect = microtime(true); try { $this->_protocol->connect($_params->host, $_params->port, $_params->ssl); } catch (Exception $e) { throw new Felamimail_Exception_IMAPServiceUnavailable($e->getMessage()); } $timeEndConnect = microtime(true); $connectTime = $timeEndConnect - $timeStartConnect; if (!$this->_protocol->login($_params->user, $_params->password)) { throw new Felamimail_Exception_IMAPInvalidCredentials('Cannot login, user or password wrong.'); } $timeEndLogin = microtime(true); $loginTime = $timeEndLogin - $timeEndConnect; if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' CONNECT TIME: ' . $connectTime . ' seconds'); } if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' LOGIN TIME: ' . $loginTime . ' seconds'); } }