Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel verify e-mail preview, render verification email

Tags:

php

laravel

For a laravel project I want to view how the verify email, email looks. I did run php artisan vendor:publish --tag=laravel-mail and in the documentation I found:

Sometimes you may wish to capture the HTML content of a mailable without sending it. To accomplish this, you may call the render method of the mailable. This method will return the evaluated contents of the mailable as a string:

$invoice = App\Invoice::find(1);

return (new App\Mail\InvoicePaid($invoice))->render();

Is it possible to do something like this for the confirm email, email? I sarched for Mailable in my project but got no results. Is ther another way to view the email without sending it?

like image 313
Sven van den Boogaart Avatar asked Oct 12 '25 17:10

Sven van den Boogaart


1 Answers

To be honest? Yes you can add routes and make them accessible locally only, but why the hassle.

Laravel already built a tool called Laravel Telescope. Just install with composer, add --dev for development only and be done with it. Set your mail driver to log and inspect without the need to hack around with routes or whatever.

If you wish to test the mail without the hassle of registering all the time, create a factory to generate and mock emails and use Tinker, or better Tinkerwell to speedup your development process.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!