notebrainslab / filament-email-templates
A powerful and flexible Email Template Management plugin for Filament v4 and v5.
Package info
github.com/notebrainslab/filament-email-templates
pkg:composer/notebrainslab/filament-email-templates
Requires
- php: ^8.2
- filament/filament: ^4.0|^5.0
- illuminate/contracts: ^11.0|^12.0
- illuminate/mail: ^11.0|^12.0
- illuminate/support: ^11.0|^12.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- orchestra/testbench: ^9.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpunit/phpunit: ^11.0
README
A sleek, powerful, and professional visual email designer for Filament v4 and v5. Build beautiful, pixel-perfect responsive email layouts using an integrated Unlayer drag-and-drop editor and integrate them into your own Laravel Mailables with ease.
β¨ Features
- π¨ Visual Drag-and-Drop Editor β Integrated Unlayer editor for professional design without writing HTML/CSS.
- π Dark Mode Support β Fully reactive dark/light theme that syncs with your Filament panel's theme toggle in real time.
- π·οΈ Smart Merge Tags β Dynamic variable support (e.g.,
{{user_name}}) with robust injection logic for both the subject and body. - π§© Mailable Integration β Use the
HasEmailTemplatetrait to power any standard Laravel Mailable from your visual templates. - π Key-Based Management β Organize your library with unique programmatic keys (e.g.
auth.welcome,order.failed). - π‘οΈ Resilient Rendering β Automatic HTML cleanup and formatting to ensure designs look great in all mail clients.
- π§ Fully Configurable Navigation β Customize the navigation group, icon, sort order, and badge visibility from your Panel Provider.
- π§Ή Clean Architecture β Design-first, no magic event listeners or forced overrides.
π Installation
Install the package via Composer:
composer require notebrainslab/filament-email-templates
Run the install command to publish migrations and config:
php artisan filament-email-templates:install
Run the migrations if you didnβt execute them during installation:
php artisan migrate
βοΈ Configuration
1. Register the Plugin
Add the plugin to your Filament Panel Provider (e.g. app/Providers/Filament/AdminPanelProvider.php):
use NoteBrainsLab\FilamentEmailTemplates\FilamentEmailTemplatesPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ FilamentEmailTemplatesPlugin::make(), ]); }
2. Plugin Options
All options are optional β the plugin works out of the box with sensible defaults.
FilamentEmailTemplatesPlugin::make() ->navigationGroup('Content') // Default: 'Email Templates' ->navigationIcon('heroicon-o-envelope-open') // Default: heroicon-o-envelope-open ->navigationSort(5) // Default: 1 ->navigationBadge(true), // Default: true β shows template count badge
| Method | Type | Default | Description |
|---|---|---|---|
navigationGroup(string) |
string |
'Email Templates' |
The sidebar group label |
navigationIcon(string) |
string |
heroicon-o-envelope-open |
Heroicon name for the nav item |
navigationSort(int) |
int |
1 |
Sort order within the nav group |
navigationBadge(bool) |
bool |
true |
Show or hide the record-count badge |
3. Unlayer Project ID (Recommended)
To enable the Dark Theme and Image Uploads in the Unlayer editor, you must set a valid Unlayer Project ID. Without it, the editor runs in anonymous demo mode and custom appearances are disabled.
- Create a free account at unlayer.com and create a Project.
- Copy the Project ID from your project settings page.
- Add it to your
.env:
UNLAYER_PROJECT_ID=YOUR_PROJECT_ID
Note: The editor works perfectly for designing and saving templates even without a Project ID. The only feature youβll miss is dark mode. That said, itβs better to create a free developer account and use your own Project ID to ensure everything is properly configured and ready for long-term use.
π‘ Usage
1. Design Your Template
Navigate to Email Templates in your Filament panel and click New Email Template.
- Name β Internal human-readable label.
- Template Key β A unique programmatic identifier (e.g.,
order.success,auth.welcome). This is what you'll reference in your Mailables. - Subject β The email subject line. Blade syntax and
{{placeholders}}are both supported. - Design β Use the full-featured Unlayer drag-and-drop editor to build your layout. Merge tags are available in the editor toolbar.
2. Use in a Laravel Mailable
Add the HasEmailTemplate trait to any standard Laravel Mailable:
namespace App\Mail; use Illuminate\Mail\Mailable; use NoteBrainsLab\FilamentEmailTemplates\Traits\HasEmailTemplate; class OrderConfirmation extends Mailable { use HasEmailTemplate; public function __construct(public $order) { // Reference the 'key' you set in the Filament panel $this->templateKey = 'order.success'; // Pass the variables your design uses as {{placeholders}} $this->templateVariables = [ 'user_name' => $this->order->customer_name, 'order_total' => $this->order->total, ]; } }
Then send it as any standard Mailable:
Mail::to($user)->send(new OrderConfirmation($order));
3. Using Placeholders
In the Unlayer editor, add {{variable_name}} placeholders as text anywhere in your design. The trait will replace them safely at send time.
Hello {{user_name}}, your order of ${{order_total}} has been confirmed!
The subject line also supports placeholders and full Blade syntax:
Your Order #{{order_total}} is Confirmed β Thanks {{user_name}}!
π Dark Mode
The Unlayer editor fully syncs with Filament's dark mode toggle:
- The editor chrome (toolbars, panels, dropdowns) switches between
modern_darkandmodern_lightthemes. - The canvas background updates between
#161616(dark) and#f9f9f9(light) dynamically. - Both the initial page load and runtime theme toggles are handled automatically β no page refresh needed.
Dark mode requires a valid
UNLAYER_PROJECT_IDto work.
π Requirements
| Dependency | Version |
|---|---|
| PHP | ^8.2 |
| Laravel | ^11.0 or ^12.0 |
| Filament | ^4.0 or ^5.0 |
π License
The MIT License (MIT). Please see the License File for more information.