How do I test an HTML Email Template on CakePHP?

This is CakePHP 1.3, but I have a feeling it may work well with 2.0 as well. While there may be other ways to do it, I do by creating a test action in any controller, then return a render call of the email template. Check this out:

function email_test()
{
    $this->layout = 'email/html/default';
    $user = $this->User->findById(1);
    $this->set('name', $user['User']['firstname']);
    $this->set('email_heading', 'Welcome to My App');
    return $this->render('/elements/email/html/welcome');
}

This action will now render out your email in the browser.

Tags:

Cakephp