public function fetchMIMEHeaders($mailbox, $uid, $parts, $mime = true)
    {
        if (!$this->select($mailbox)) {
            return false;
        }

        $result = false;
        $parts  = (array) $parts;
        $key    = $this->nextTag();
        $peeks  = array();
        $type   = $mime ? 'MIME' : 'HEADER';

        // format request
        foreach ($parts as $part) {
            $peeks[] = "BODY.PEEK[$part.$type]";
        }

        $request = "$key UID FETCH $uid (" . implode(' ', $peeks) . ')';

        // send request
        if (!$this->putLine($request)) {
            $this->setError(self::ERROR_COMMAND, "Failed to send UID FETCH command");
            return false;
        }

        do {
            $line = $this->readLine(1024);

            if (preg_match('/^\* [0-9]+ FETCH [0-9UID( ]+/', $line, $m)) {
                $line = ltrim(substr($line, strlen($m[0])));
                while (preg_match('/^BODY\[([0-9\.]+)\.'.$type.'\]/', $line, $matches)) {
                    $line = substr($line, strlen($matches[0]));
                    $result[$matches[1]] = trim($this->multLine($line));
                    $line = $this->readLine(1024);
                }
            }
        }
        while (!$this->startsWith($line, $key, true));

        return $result;
    }