spatie/laravel-mail-preview
Adds a “preview” mail transport for Laravel that captures outgoing emails and shows a small in-browser overlay with a link to view the last sent mail—ideal for local development and testing without actually delivering mail.
composer require spatie/laravel-mail-previewconfig/mail.php: set the transport for your mailer (e.g., smtp) to 'preview'app/Http/Kernel.php: add \Spatie\MailPreview\Http\Middleware\AddMailPreviewOverlayToResponse::class to the web groupRoute::mailPreview(); in routes/web.phpAPP_DEBUG=true, and the overlay link will appear at the bottom-right of your screenpreview driver exclusively in non-production environments (e.g., via .env (MAIL_MAILER=preview) or conditional config loading)Mail::fake() with SentMails::fake() in feature tests to assert mail content (e.g., SentMails::assertLastContains('Dear John'))popup_timeout_in_seconds and show_link_to_preview in the published config to control how long the preview overlay stays visible.html files directly in a browser to test responsiveness and rendering — the inline comment at the top contains full metadatavendor:publish --tag=mail-preview-views) to modify the preview layout, overlay styling, or integrate with your app’s design systemmaximum_lifetime_in_seconds (default: 60s) — increase this if debugging long workflows or during slow CI runs'filename_date_format' => 'u'); if generating emails rapidly, consider increasing precision or adding UUIDs in custom event listenersSentMails assertions or check storage/email-previews manually when sending from Artisan commands or jobsSendResponseWithoutFlashes but after ShareErrorsFromSession)SentMails::fake() must be called before triggering the action (like Mail::to()->send()), otherwise sent emails won’t be capturedmail or smtp transports, but not log — log won’t store previews or trigger eventsHow can I help you explore Laravel packages today?