Download the PHP package dynamik-dev/laravel-mail-preview without Composer
On this page you can find all versions of the php package dynamik-dev/laravel-mail-preview. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dynamik-dev/laravel-mail-preview
More information about dynamik-dev/laravel-mail-preview
Files in dynamik-dev/laravel-mail-preview
Package laravel-mail-preview
Short Description A utility for viewing emails in your browser as you develop.
License MIT
Homepage https://github.com/dynamik-dev/laravel-mail-preview
Informations about the package laravel-mail-preview
A utility for viewing emails in your browser as you develop with Laravel. This package allows you to preview your mailables without actually sending emails, making it easier to develop and test your email templates.
Then, view it instantly at 👀 http://your-app.test/mail/welcome-email
Table of Contents
- How to use
- 1. Make Your Mailable Previewable
- 2. View Your Email Preview
- 3. Custom Preview Slugs
- Installation
- Requirements
- Configuration
- Environment Variables
- Security
- Testing
- Contributing
- Credits
- License
Think of it like Factories for your emails.
How to use
1. Make Your Mailable Previewable
To make a mailable previewable, implement the Previewable
interface and add the toPreview()
method:
2. View Your Email Preview
Once you've made your mailable previewable, you can view it in your browser at:
The URL slug is automatically generated from your class name:
WelcomeEmail
→welcome-email
OrderConfirmationMail
→order-confirmation-mail
TestMailable
→test-mailable
3. Custom Preview Slugs
You can also define a custom preview slug by adding a static property to your mailable:
Now you can access it at: http://your-app.test/mail/welcome
Installation
You can install the package via Composer:
The package will automatically register itself with Laravel.
Requirements
- PHP 8.4+
- Laravel 10.x, 11.x, or 12.x
Configuration
Publish the configuration file:
This will create a config/mail-preview.php
file with the following options:
Environment Variables
To enable the mail preview, set MAIL_PREVIEW_ENABLED
to true
in your .env
file.
These are the available options:
Security
Important: This package should only be enabled in development environments. The mail preview routes expose your email templates and could potentially leak sensitive information.
Make sure to:
- Set
MAIL_PREVIEW_ENABLED=false
in production - Add the preview routes to your middleware if needed
- Consider using authentication middleware for the preview routes
Testing
Run the test suite:
Contributing
Please see CONTRIBUTING.md for details.
Credits
- Chris Arter
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-mail-preview with dependencies
illuminate/contracts Version ^10.0||^11.0||^12.0
spatie/laravel-package-tools Version ^1.16
spatie/php-structure-discoverer Version ^2.3