function mail_headers($args)
    {
        // this hook can be executed many times
        if ($this->mail_headers_done) {
            return $args;
        }

        $this->mail_headers_done = true;

        $headers = $this->parse_headers($args['headers']);

        if ($this->rc->action == 'preview')
            $this->rc->output->command('parent.set_env', array('sieve_headers' => $headers));
        else
            $this->rc->output->set_env('sieve_headers', $headers);

        return $args;
    }