klein / klein.php

A fast & flexible router
MIT License
2.67k stars 289 forks source link

Feature request, retrieve HTML from render. #205

Open BCleverly opened 10 years ago

BCleverly commented 10 years ago

This feature would be nice for generating HTML emails.

I'm using Klein in conjunction with SwiftMailer.

I'm aiming to send HTML emails for my contact forms. Was wondering if I could pass the variables to Klein with the view to render then pass that HTML code on to SwiftMailer to send out.

Or is there a method to handle this already?

AgelxNash commented 9 years ago

:hankey: hardcore

$service->partial('tpl/mail.html');
$message = Swift_Message::newInstance()
        ->setBody(ob_get_contents(), 'text/html');
$result = $mailer->send($message);
ob_clean();

$service->render('tpl/page/send.html');
``