public function buildMessage(ParserInterface $parser, \Swift_Message $messageInstance, $useFallbackTemplate = true)
    {
        // Set mail template, and save the current template
        $parser->pushTemplateDefinition(
            $parser->getTemplateHelper()->getActiveMailTemplate(),
            $useFallbackTemplate
        );

        $subject     = $parser->renderString($this->getSubject());
        $htmlMessage = $this->getHtmlMessageBody($parser);
        $textMessage = $this->getTextMessageBody($parser);

        $messageInstance->setSubject($subject);

        // If we do not have an HTML message
        if (empty($htmlMessage)) {
            // Message body is the text message
            $messageInstance->setBody($textMessage, 'text/plain');
        } else {
            // The main body is the HTML messahe
            $messageInstance->setBody($htmlMessage, 'text/html');

            // Use the text as a message part, if we have one.
            if (! empty($textMessage)) {
                $messageInstance->addPart($textMessage, 'text/plain');
            }
        }

        // Restore previous template
        $parser->popTemplateDefinition();

        return $messageInstance;
    }
public function buildMessage(ParserInterface $parser, \Swift_Message $messageInstance, $useFallbackTemplate = true)
    {
        // Set mail template, and save the current template
        $parser->pushTemplateDefinition(
            $parser->getTemplateHelper()->getActiveMailTemplate(),
            $useFallbackTemplate
        );

        $subject     = $parser->renderString($this->getSubject());
        $htmlMessage = $this->getHtmlMessageBody($parser);
        $textMessage = $this->getTextMessageBody($parser);

        $messageInstance->setSubject($subject);

        // If we do not have an HTML message
        if (empty($htmlMessage)) {
            // Message body is the text message
            $messageInstance->setBody($textMessage, 'text/plain');
        } else {
            // The main body is the HTML messahe
            $messageInstance->setBody($htmlMessage, 'text/html');

            // Use the text as a message part, if we have one.
            if (! empty($textMessage)) {
                $messageInstance->addPart($textMessage, 'text/plain');
            }
        }

        // Restore previous template
        $parser->popTemplateDefinition();

        return $messageInstance;
    }
public function buildMessage ( ParserInterface $ parser , \ Swift_Message $ messageInstance , $ useFallbackTemplate = true ) { // Set mail template, and save the current template $ parser -> pushTemplateDefinition ( $ parser -> getTemplateHelper ( ) -> getActiveMailTemplate ( ) , $ useFallbackTemplate ) ; $ subject = $ parser -> renderString ( $ this -> getSubject ( ) ) ; $ htmlMessage = $ this -> getHtmlMessageBody ( $ parser ) ; $ textMessage = $ this -> getTextMessageBody ( $ parser ) ; $ messageInstance -> setSubject ( $ subject ) ; // If we do not have an HTML message if ( empty ( $ htmlMessage ) ) { // Message body is the text message $ messageInstance -> setBody ( $ textMessage , 'text/plain' ) ; } else { // The main body is the HTML messahe $ messageInstance -> setBody ( $ htmlMessage , 'text/html' ) ; // Use the text as a message part, if we have one. if ( ! empty ( $ textMessage ) ) { $ messageInstance -> addPart ( $ textMessage , 'text/plain' ) ; } } // Restore previous template $ parser -> popTemplateDefinition ( ) ; return $ messageInstance ; }
Add a subject and a body (TEXT, HTML or both, depending on the message
configuration.

@param  ParserInterface $parser
@param  \Swift_Message  $messageInstance
@param  bool            $useFallbackTemplate When we send mail from a module and don't use the `default` email
template, if the file (html/txt) is not found in the template then
the template file located in the module under
`templates/email/default/' directory is used if
`$useFallbackTemplate` is set to `true`.
@return \Swift_Message
@throws \SmartyException
Add a subject and a body ( TEXT HTML or both depending on the message configuration .