Preview your notification emails in Laravel 5.4

Oscar Mwanandimai
1 min readAug 21, 2017

--

If you want to preview you mails in browser to see how they would ideally look in the recipient’s inbox you can set that up in a few lines of code in your routes file.

The solution is a Frankenstein mashup of tips from two different sources. One was a great tip from Adam Wathan(above) and the other a solution by TiBian on a Laracast thread because Laravel Notifications are now in markdown by default.

The snippet below assumes you have created a notification called TestNotification that has no data passed to it.

// routes/web.php$this->get(‘preview-notification’, function () {
$message = (new \App\Notifications\TestNotification())->toMail('test@email.com');

$markdown = new \Illuminate\Mail\Markdown(view(), config(‘mail.markdown’));
return $markdown->render(‘vendor.notifications.email’, $message->toArray());});

I hope this nudges you in the right direction.

--

--