public function createMessage(string $templatePath, array $context): Message
    {
        $template = $this->twig->loadTemplate($templatePath);
        $context = $this->twig->mergeGlobals($context);

        return new Message(
            $this->renderBlock($template, 'title', $context),
            $this->renderBlock($template, 'subject', $context),
            $this->createMessageContent($template, $context),
            EmailAddresses::fromString(trim($this->renderBlock($template, 'to', $context))),
            EmailAddresses::fromString(trim($this->renderBlock($template, 'cc', $context))),
            EmailAddresses::fromString(trim($this->renderBlock($template, 'bcc', $context))),
            EmailAddress::fromString(trim($this->renderBlock($template, 'sender', $context))),
            EmailAddresses::fromString(trim($this->renderBlock($template, 'from', $context)))
        );
    }
public function createMessage(string $templatePath, array $context): Message
    {
        $template = $this->twig->loadTemplate($templatePath);
        $context = $this->twig->mergeGlobals($context);

        return new Message(
            $this->renderBlock($template, 'title', $context),
            $this->renderBlock($template, 'subject', $context),
            $this->createMessageContent($template, $context),
            EmailAddresses::fromString(trim($this->renderBlock($template, 'to', $context))),
            EmailAddresses::fromString(trim($this->renderBlock($template, 'cc', $context))),
            EmailAddresses::fromString(trim($this->renderBlock($template, 'bcc', $context))),
            EmailAddress::fromString(trim($this->renderBlock($template, 'sender', $context))),
            EmailAddresses::fromString(trim($this->renderBlock($template, 'from', $context)))
        );
    }
public function createMessage ( string $ templatePath , array $ context ) : Message { $ template = $ this -> twig -> loadTemplate ( $ templatePath ) ; $ context = $ this -> twig -> mergeGlobals ( $ context ) ; return new Message ( $ this -> renderBlock ( $ template , 'title' , $ context ) , $ this -> renderBlock ( $ template , 'subject' , $ context ) , $ this -> createMessageContent ( $ template , $ context ) , EmailAddresses :: fromString ( trim ( $ this -> renderBlock ( $ template , 'to' , $ context ) ) ) , EmailAddresses :: fromString ( trim ( $ this -> renderBlock ( $ template , 'cc' , $ context ) ) ) , EmailAddresses :: fromString ( trim ( $ this -> renderBlock ( $ template , 'bcc' , $ context ) ) ) , EmailAddress :: fromString ( trim ( $ this -> renderBlock ( $ template , 'sender' , $ context ) ) ) , EmailAddresses :: fromString ( trim ( $ this -> renderBlock ( $ template , 'from' , $ context ) ) ) ) ; }
Create a new e-mail message from the given template.

@param string $templatePath A path to the template file.
@param mixed[] $context The template context.

@return Message Newly created e-mail message.
Create a new e - mail message from the given template .