// Thrown on CATENATE if the message was too big.
const CATENATE_TOOBIG = 14;
+ // Login failures
+
+ // Could not start mandatory TLS connection.
+ const LOGIN_TLSFAILURE = 15;
+
+ // Could not find an available authentication method.
+ const LOGIN_NOAUTHMETHOD = 16;
+
+ // Generic authentication failure.
+ const LOGIN_AUTHENTICATIONFAILED = 17;
+
+ // Remote server is unavailable.
+ const LOGIN_UNAVAILABLE = 18;
+
+ // Authentication succeeded, but authorization failed.
+ const LOGIN_AUTHORIZATIONFAILED = 19;
+
+ // Authentication is no longer permitted with this passphrase.
+ const LOGIN_EXPIRED = 20;
+
+ // Login requires privacy.
+ const LOGIN_PRIVACYREQUIRED = 21;
+
/**
* Define a callback function used to log the exception. Will be passed
* a single parameter - a copy of this object.
call_user_func(self::$logCallback, $this);
}
}
+
}
if (!$res) {
$this->logout();
- throw new Horde_Imap_Client_Exception('Could not open secure TLS connection to the IMAP server.');
+ throw new Horde_Imap_Client_Exception('Could not open secure TLS connection to the IMAP server.', Horde_Imap_Client_Exception::LOGIN_TLSFAILURE);
}
// Expire cached CAPABILITY information (RFC 3501 [6.2.1])
}
if (empty($imap_auth_mech)) {
- throw new Horde_Imap_Client_Exception('No supported IMAP authentication method could be found.');
+ throw new Horde_Imap_Client_Exception('No supported IMAP authentication method could be found.', Horde_Imap_Client_Exception::LOGIN_NOAUTHMETHOD);
}
/* Use MD5 authentication first, if available. But no need to use
$imap_auth_mech = array($this->_init['authmethod']);
}
+ /* Default to AUTHENTICATIONFAILED error (see RFC 5530[3]). */
+ $t['loginerr'] = Horde_Imap_Client_Exception::LOGIN_AUTHENTICATIONFAILED;
+
foreach ($imap_auth_mech as $method) {
$t['referral'] = null;
}
}
- throw new Horde_Imap_Client_Exception('IMAP server denied authentication.');
+ throw new Horde_Imap_Client_Exception('IMAP server denied authentication.', $t['loginerr']);
}
/**
}
if (!empty($this->_params['secure']) && !extension_loaded('openssl')) {
- throw new Horde_Imap_Client_Exception('Secure connections require the PHP openssl extension.');
+ throw new Horde_Imap_Client_Exception('Secure connections require the PHP openssl extension.', Horde_Imap_Client_Exception::SERVER_CONNECT);
}
switch ($this->_params['secure']) {
switch ($ob['response']) {
case 'BAD':
// Server is rejecting our connection.
- throw new Horde_Imap_Client_Exception('Server rejected connection: ' . $ob['line']);
+ throw new Horde_Imap_Client_Exception('Server rejected connection: ' . $ob['line'], Horde_Imap_Client_Exception::SERVER_CONNECT);
case 'PREAUTH':
// The user was pre-authenticated.
// Check for IMAP4rev1 support
if (!$this->queryCapability('IMAP4REV1')) {
- throw new Horde_Imap_Client_Exception('This server does not support IMAP4rev1 (RFC 3501).');
+ throw new Horde_Imap_Client_Exception('This server does not support IMAP4rev1 (RFC 3501).', Horde_Imap_Client_Exception::SERVER_CONNECT);
}
// Set language if not using imapproxy
switch ($code) {
case 'ALERT':
+ // Defined by RFC 5530 [3] - Treat as an alert for now.
+ case 'CONTACTADMIN':
if (!isset($this->_temp['alerts'])) {
$this->_temp['alerts'] = array();
}
case 'UNAVAILABLE':
// Defined by RFC 5530 [3]
+ $this->_temp['loginerr'] = Horde_Imap_Client_Exception::LOGIN_UNAVAILABLE;
break;
case 'AUTHENTICATIONFAILED':
// Defined by RFC 5530 [3]
+ $this->_temp['loginerr'] = Horde_Imap_Client_Exception::LOGIN_AUTHENTICATIONFAILED;
break;
case 'AUTHORIZATIONFAILED':
// Defined by RFC 5530 [3]
+ $this->_temp['loginerr'] = Horde_Imap_Client_Exception::LOGIN_AUTHORIZATIONFAILED;
break;
case 'EXPIRED':
// Defined by RFC 5530 [3]
+ $this->_temp['loginerr'] = Horde_Imap_Client_Exception::LOGIN_EXPIRED;
break;
case 'PRIVACYREQUIRED':
// Defined by RFC 5530 [3]
- break;
-
- case 'CONTACTADMIN':
- // Defined by RFC 5530 [3]
+ $this->_temp['loginerr'] = Horde_Imap_Client_Exception::LOGIN_PRIVACYREQUIRED;
break;
case 'NOPERM':