Preview Mail Notification in browser
In your controller's function :
$message = (new \App\Notifications\MyNotification())->toMail('[email protected]');
$markdown = new \Illuminate\Mail\Markdown(view(), config('mail.markdown'));
return $markdown->render('vendor.notifications.email', $message->data());
Just change the name of the notification class (and also pass arguments if necessary) and hit the url in your browser to see the preview.
You can't render Notification. You can render Mailable that you use in toMail()
. For example if that Mailable is called SomeMailable
:
public function toMail($user)
{
return (new SomeMailable($user))->to($user->email);
}
Then you can render the Mailable with:
return new SomeMailable($some_user);
In Laravel 5.8 you can now preview it just like you would a Mailable.
Route::get('mail-preview', function () {
return (new MyNotification())->toMail($some_user);
});
More details here: https://sampo.co.uk/blog/previewing-mail-notifications-in-laravel-just-got-easier