public function render()
  {
    if (!$this->getTemplate())
    {
      throw new MailerException('You must call setTemplate() to set a mail template');
    }
    
    $template = $this->getTemplate();
    
    $template =  $this->mailerManager->updateTemplate($template,$this->getValues());
    $replacements = $this->getReplacements();
    //load the template content
    $templateFile = 'KRSMailBundle:mailTemplate:karisMailTemplate.html.twig';
    $templateContent = $this->twig->loadTemplate($templateFile);
    
    $body = $templateContent->render(array('body' =>strtr($template->getBody(), $replacements)));
    
    $message = $this->getMessage();

    $from = array($template->getFromEmail() => "KRS");
    $message
    ->setSubject(strtr($template->getSubject(), $replacements))
    ->setBody(strtr($body, $replacements),'text/html')
    ->setContentType("text/html")
    ->setFrom($from)
    ->setTo($this->emailListToArray(strtr($template->getToEmail(), $replacements)));

    if($template->getCcEmail())
    {
    	$message->setCc($this->emailListToArray(strtr($template->getCcEmail(), $replacements)));
    }
    
    if($template->getBccEmail())
    {
    	$message->setBcc($this->emailListToArray(strtr($template->getBccEmail(), $replacements)));
    }
    
    if($template->getReplyToEmail())
    {
    	$message->setReplyTo($this->emailListToArray(strtr($template->getReplyToEmail(), $replacements)));
    }
    
    if($template->getSenderEmail())
    {
    	$message->setSender($this->emailListToArray(strtr($template->getSenderEmail(), $replacements)));
    }

    $this->isRendered = true;

    return $this;
  }