if (!is_null($this->_stream)) {
if (empty($this->_temp['logout'])) {
$this->_temp['logout'] = true;
- try {
- $this->_sendLine('LOGOUT');
- } catch (Horde_Imap_Client_Exception $e) {}
+ $this->_sendLine('LOGOUT', array('errignore' => true));
}
unset($this->_temp['logout']);
@fclose($this->_stream);
// RFC 3501 [6.4.2]: to close a mailbox without expunge,
// select a non-existent mailbox. Selecting a null mailbox
// should do the trick.
- try {
- $this->_sendLine('SELECT ""');
- } catch (Horde_Imap_Client_Exception $e) {
- // Ignore - we are expecting a NO return.
- }
+ $this->_sendLine('SELECT ""', array('errignore' => true));
}
} else {
// If caching, we need to know the UIDs being deleted, so call
* 'debug' - (string) When debugging, send this string instead of the
* actual command/data sent.
* DEFAULT: Raw data output to debug stream.
+ * 'errignore' - (boolean) Don't throw error on BAD/NO response.
+ * DEFAULT: false
* 'literal' - (integer) Send the command followed by a literal. The value
* of 'literal' is the length of the literal data.
* Will attempt to use LITERAL+ capability if possible.
throw new Horde_Imap_Client_Exception('Unexpected response from IMAP server while waiting for a continuation request: ' . $ob['line']);
}
} elseif (empty($options['noparse'])) {
- $this->_parseResponse($this->_tag);
+ $this->_parseResponse($this->_tag, !empty($options['errignore']));
} else {
return $this->_getLine();
}
/**
* Parse all untagged and tagged responses for a given command.
*
- * @param string $tag The IMAP tag of the current command.
+ * @param string $tag The IMAP tag of the current command.
+ * @param boolean $ignore If true, don't throw errors.
*
* @throws Horde_Imap_Client_Exception
*/
- protected function _parseResponse($tag)
+ protected function _parseResponse($tag, $ignore)
{
while ($ob = $this->_getLine()) {
if (($ob['type'] == 'tagged') && ($ob['tag'] == $tag)) {
switch ($ob['response']) {
case 'BAD':
case 'NO':
+ if ($ignore) {
+ return;
+ }
+
if (empty($this->_temp['parsestatuserr'])) {
$errcode = 0;
$errstr = empty($ob['line']) ? '[No error message returned by server.]' : $ob['line'];
if ($ob['response'] == 'BAD') {
throw new Horde_Imap_Client_Exception('Bad IMAP request: ' . $errstr, $errcode);
- } else {
- throw new Horde_Imap_Client_Exception('IMAP error: ' . $errstr, $errcode);
}
+
+ throw new Horde_Imap_Client_Exception('IMAP error: ' . $errstr, $errcode);
}
/* Update the cache, if needed. */