public function renderMail($config = array())
    {
        $config = new AnConfig($config);

        $config->append(array(
            'layout' => 'default',
        ));

        $layout = $config->layout;
        $data = $this->getState()->toArray();

        if ($this->getState()->getItem()) {
            $data[$this->_mixer->getIdentifier()->name] = $this->getState()->getItem();
        }

        if ($this->getState()->getList()) {
            $data[AnInflector::pluralize($this->_mixer->getIdentifier()->name)] = $this->getState()->getList();
        }

        $config->append(array(
            'data' => $data
        ));

        $template = $this->getEmailTemplateView()->getTemplate();
        $data = array_merge($config['data'], array('config' => $config));

        if ($layout && $template->findTemplate($layout)) {
            $output = $template->loadTemplate($layout, array('output' => $output))->render();
        } else {
            $output = $template->loadTemplate($config->template, $data)->render();
        }

        return $output;
    }