MailWeb is a robust Laravel package that revolutionizes email development and debugging. It seamlessly captures and displays your application's outgoing emails in real-time, making email testing and sharing effortless.
- π§ Real-time Email Interception: Catch and inspect outgoing emails instantly
- π¨ Modern UI: Beautiful, responsive interface for easy navigation
- π Powerful Search: Quickly find emails with advanced search capabilities
- π Email Sharing: Share email previews with your team effortlessly
- π Attachment Support: Handle email attachments with flexible storage options
- π‘οΈ Secure Access Control: Granular control over who can access the dashboard
- π± Mobile Responsive: Optimized interface for both desktop and mobile devices
- PHP 8.1 or higher
- Laravel 9.21|10.0|11.0|12.0
- Install via Composer:
composer require appoly/mail-web- Run migrations:
php artisan migrate- Publish config (if needed):
php artisan vendor:publish --tag=mailweb-config --forceAdd to your routes file:
Route::mailweb();By default, access to the MailWeb dashboard may be restricted to local environments. To control access in specific environments (like production or staging), you should define a Gate in AppServiceProvider (Laravel 11+) or AuthServiceProvider.
The gate name must be 'view-mailweb'. You can choose the logic that best fits your workflow below.
This is the most flexible method for small teams. It allows you to grant access via your .env file without redeploying code.
1. Add to your .env file:
MAILWEB_ALLOWED_EMAILS="admin@company.com,developer@agency.com"2. Add to your config/services.php file:
'mailweb' => [
'authorized_users' => explode(',', env('MAILWEB_ALLOWED_EMAILS', '')),
]3. Add to AppServiceProvider::boot():
use Illuminate\Support\Facades\Gate;
public function boot()
{
Gate::define('view-mailweb', function ($user = null) {
// Get emails from mailweb config, split by comma
$allowed = config('services.mailweb.authorized_users', []);
// Check if user is logged in AND their email is in the list
return $user && in_array($user->email, $allowed);
});
}If your application uses a role management system (like a role column, is_admin boolean, or Spatie Permissions), use that as your source of truth.
Add to AppServiceProvider::boot():
use Illuminate\Support\Facades\Gate;
public function boot()
{
Gate::define('view-mailweb', function ($user = null) {
// Example: Check a boolean column
// return $user && $user->is_admin;
// Example: Check a specific role string
// return $user && $user->role === 'admin';
});
}Use this if you want to allow everyone (including guests/non-logged-in users) to view the emails, but only on specific environments.
Add to AppServiceProvider::boot():
use Illuminate\Support\Facades\Gate;
public function boot()
{
Gate::define('view-mailweb', function ($user = null) {
// β οΈ Allows anyone to view emails if the environment matches
return app()->environment('local', 'staging');
});
}For local development, set in your .env:
MAIL_MAILER=log- Access the dashboard at:
{your-app-url}/mailweb
- Configure email storage limit in
.env:
MAILWEB_LIMIT=30 # Default value- Set up email pruning (recommended in
routes/console.php):
use Illuminate\Support\Facades\Schedule;
Schedule::command('mailweb:prune')->daily();Configure attachment storage in your .env:
MAILWEB_ATTACHMENTS_DISK=s3 # Or any configured disk
MAILWEB_ATTACHMENTS_PATH=/custom/path # Optional, defaults to /mailweb/attachmentsWe welcome contributions! Please follow these steps:
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
- Clone the repository
- Install dependencies:
composer install- Link to your test project - add to your test project's
composer.json:
{
"repositories": [
{
"type": "path",
"url": "../path/to/MailWeb",
"options": {
"symlink": true
}
}
],
"require": {
"appoly/mail-web": "@dev"
}
}- Run
composer update appoly/mail-web
This project is licensed under the MIT License.