Return Mailable instances directly from route callbacks to preview compiled HTML emails in your browser without sending test emails.
Testing email layouts by sending real test emails to inboxes slows down design iterations. Returning a Mailable object directly from a route renders the HTML output live in your browser.
use App\Mail\OrderShipped;
use App\Models\Order;
use Illuminate\Support\Facades\Route;
Route::get('/mailable-preview', function () {
$order = Order::first();
return new OrderShipped($order); // Renders compiled HTML email directly in browser
});
- Renders compiled Blade HTML email template live in browser
- Speeds up email design and responsive layout iterations
- No external mail server or SMTP trap configuration needed
Related Tips
View all tips →Scaffold Actions, Builders, and Collections with Artisan
Extend your generator commands to scaffold common domain patterns like Actions, Custom Query Builders, and Collections directly via Artisan.
Customize Artisan Code Generators with stub:publish
Publish and customize Artisan generator stubs using php artisan stub:publish to enforce custom code conventions across your team.