ezcMailImapTransport::getResponse PHP Method

getResponse() protected method

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.
protected getResponse ( string $tag, string $response = null ) : string
$tag string
$response string
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;
    }