Render an e-mail template in the browser
13
To preview an e-mail template directly in the browser, add a temporary route to your plugin's routes.php
file:
// plugins/yourvendor/yourplugin/routes.php
use System\Classes\MailManager;
use System\Models\MailLayout;
use System\Models\MailTemplate;
Route::get('/mail', function () {
$data = [
'your-dummy' => 'data',
];
$layout = new MailLayout;
$layout->fillFromCode('default'); // Change this to use another layout.
$template = new MailTemplate;
$template->layout = $layout;
$template->fillFromContent(File::get(base_path('plugins/path/to/your/views/template.htm')));
return MailManager::instance()->renderTemplate($template, $data);
});
Now visit http://yoursite.test/mail
to preview the mail in your browser. Don't forget to remove this route once you are done!
There are no comments yet
Be the first one to comment