public function createMessageFromTemplateEntity(EmailTemplate $template, array $parameters = array())
    {
        $subject = $this->renderStringTemplate($template->getSubject(), $parameters);
        $recipient = $this->renderStringTemplate($template->getRecipient(), $parameters);
        $body = $this->renderStringTemplate($template->getBody(), $parameters);
        $sender = $template->getSender() ?: $this->defaultSender;

        $message = new \Swift_Message($subject, $body, $template->getMimeType());
        $message->setFrom($sender)
                ->setSender($sender)
                ->setTo($recipient);

        if ($template->hasCc()) {
            $message->setCc($template->getCc());
        }

        if ($template->hasAltBody()) {
            $altBody = $this->renderStringTemplate($template->getAltBody(), $parameters);
            $message->addPart($altBody, $template->getAltMimeType());
        }

        return $message;
    }