Helper/EmailHelper.php
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;
    }
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;
    }
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 ; }
Create Message from an EmailTemplate entity

@param \Orkestra\Bundle\ApplicationBundle\Entity\EmailTemplate $template
@param array $parameters An array of parameters to pass to the the templating engine
@return \Swift_Message
Create Message from an EmailTemplate entity