Example #1
0
 /**
  * Reads the responses from the server until encountering $tag.
  *
  * In IMAP, each command sent by the client is prepended with a
  * alphanumeric tag like 'A1234'. The server sends the response
  * to the client command as lines, and the last line in the response
  * is prepended with the same tag, and it contains the status of
  * the command completion ('OK', 'NO' or 'BAD').
  *
  * Sometimes the server sends alerts and response lines from other
  * commands before sending the tagged line, so this method just
  * reads all the responses until it encounters $tag.
  *
  * It returns the tagged line to be processed by the calling method.
  *
  * If $response is specified, then it will not read the response
  * from the server before searching for $tag in $response.
  *
  * Before calling this method, a connection to the IMAP server must be
  * established.
  *
  * @param string $tag
  * @param string $response
  * @return string
  */
 protected function getResponse($tag, $response = null)
 {
     if (is_null($response)) {
         $response = $this->connection->getLine();
     }
     while (strpos($response, $tag) === false) {
         if (strpos($response, ' BAD ') !== false || strpos($response, ' NO ') !== false) {
             break;
         }
         $response = $this->connection->getLine();
     }
     return $response;
 }
Example #2
0
 /**
  * Sends a NOOP command to the server, use it to keep the connection alive.
  *
  * Before calling this method, a connection to the POP3 server must be
  * established and a user must be authenticated successfully.
  *
  * @throws ezcMailTransportException
  *         if there was no connection to the server
  *         or if not authenticated
  *         or if the server sent a negative response
  */
 public function noop()
 {
     if ($this->state != self::STATE_TRANSACTION) {
         throw new ezcMailTransportException("Can't call noop() on the POP3 transport when not successfully logged in.");
     }
     // send the command
     $this->connection->sendData("NOOP");
     $response = $this->connection->getLine();
     if (!$this->isPositiveResponse($response)) {
         throw new ezcMailTransportException("The POP3 server sent a negative response to the NOOP command: {$response}.");
     }
 }