private function remove_flag_from_message($messageid, $flag) {
        // Get the current mailbox.
        $mailbox = $this->get_mailbox();

        // Mark it as read to lock the message.
        $this->client->store($mailbox, array(
            'ids' => $messageid,
            'delete' => $flag,
        ));
    }