Skip to content

Instantly share code, notes, and snippets.

@motsmanish
Last active July 18, 2018 21:16
Show Gist options
  • Save motsmanish/223a44eb99c098da0419c64004a46c6a to your computer and use it in GitHub Desktop.
Save motsmanish/223a44eb99c098da0419c64004a46c6a to your computer and use it in GitHub Desktop.
Render email template in library for passing email body as a paramenter in CakePHP 3. (needed this for SendGrid)
$template = 'dump';
$layout = false;
$view = new View(new \Cake\Network\Request, new \Cake\Network\Response);
foreach ($vars as $key => $value) {
$view->set($key, $value);
}
$view->viewPath = 'Email\html'; \\src\Template\Email\html
$view_output = $view->render($template, $layout);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment