public function generateMessage(EmailInterface $email, $to, array $parameters = array(), $locale = null)
    {
        if (null === $locale) {
            $locale = $this->options['default_locale'];
        }

        if (is_object($to)) {
            $to = $this->getRecipient($to);
        }

        try {
            $email->setLocale($locale);
            $this->renderer->loadTemplates($email);

            $message = $this->createMessageInstance()
                            ->setSubject($this->renderTemplate('subject', $parameters, $email->getChecksum()))
                            ->setFrom($this->renderFromAddress($email, $parameters), $this->renderTemplate('from_name', $parameters, $email->getChecksum()))
                            ->setTo($to)
                            ->setBody($this->renderTemplate('html_content', $parameters, $email->getChecksum()), 'text/html');

            $textContent = $this->renderTemplate('text_content', $parameters, $email->getChecksum());

            if (null !== $textContent && '' !== $textContent) {
                $message->addPart($textContent, 'text/plain');
            }

            foreach ($email->getBccs() as $bcc) {
                $message->addBcc($bcc);
            }

            if (count($email->getHeaders()) > 0) {
                $headers = $message->getHeaders();
                foreach ($email->getHeaders() as $header) {
                    if (is_array($header) && isset($header['key'], $header['value'])) {
                        $headers->addTextHeader($header['key'], $header['value']);
                    }
                }
            }

        } catch (NoTranslationException $e) {
            $message = new NoTranslationMessage($email->getReference(), $locale);
            $message->setFrom($this->options['admin_email']);
            $message->setTo($this->options['admin_email']);

        } catch (\Twig_Error_Runtime $e) {
            $message = new UndefinedVariableMessage($e->getMessage(), $email->getReference());
            $message->setFrom($this->options['admin_email']);
            $message->setTo($this->options['admin_email']);

        } catch (\Twig_Error $e) {
            $message = new TwigErrorMessage($e->getRawMessage(), $email->getReference());
            $message->setFrom($this->options['admin_email']);
            $message->setTo($this->options['admin_email']);
        }

        return $message;
    }