spatie/mailcoach-ui
UI add-on for spatie/laravel-mailcoach. Provides the frontend assets and interface for the Mailcoach app, with maintained tests and static analysis. Documentation available on the Mailcoach site.
Install Dependencies
Ensure spatie/laravel-mailcoach is installed first (core email marketing functionality).
composer require spatie/laravel-mailcoach
Then install the UI package:
composer require spatie/mailcoach-ui
Publish Assets & Config Run the publisher for assets and configuration:
php artisan vendor:publish --provider="Spatie\Mailcoach\MailcoachServiceProvider" --tag="mailcoach-assets"
php artisan vendor:publish --provider="Spatie\Mailcoach\MailcoachServiceProvider" --tag="mailcoach-config"
mailcoach.ui.enabled).Run Migrations Mailcoach requires database tables for campaigns, subscribers, etc.:
php artisan migrate
First Use Case: Launch the UI
/mailcoach (or your configured route).php artisan make:auth if not set up).mailcoach user created during installation (check users table).Campaign Management
Subscriber Management
queue:work).
Mailcoach::subscribers()->create() for programmatic additions.active, vip) or custom fields.
$subscribers = Mailcoach::subscribers()
->where('tags', 'like', '%vip%')
->get();
Automation
user.registered) via:
event(new Registered($user));
// Trigger workflow via Mailcoach API:
Mailcoach::workflows()->trigger('welcome_sequence', $user->email);
Analytics
$stats = Mailcoach::campaigns()->find(1)->stats();
Laravel Events: Tie Mailcoach to Laravel’s ecosystem by listening to events:
// Example: Send a welcome email when a user registers
Event::listen(Registered::class, function ($user) {
Mailcoach::campaigns()->find(1)->sendTo($user->email);
});
API Access: Use the underlying API for custom logic:
// Send a campaign via API
$response = Http::post('/api/mailcoach/campaigns/1/send');
Custom Fields:
Extend subscriber data with custom fields (e.g., company_name):
// Add a custom field to a subscriber
$subscriber = Mailcoach::subscribers()->create([
'email' => 'user@example.com',
'custom_fields' => ['company_name' => 'Acme Corp'],
]);
Theming: Override default UI assets by publishing and modifying:
php artisan vendor:publish --tag=mailcoach-assets --force
/resources/views/vendor/mailcoach/ for Blade templates./resources/js/mailcoach/ for Vue components.Asset Loading Issues
public_path() is correct in config/mailcoach.php and run:
npm run dev # or `npm run prod` for production
php artisan optimize:clear
Authentication Bypass
/mailcoach routes are accessible without auth.config/mailcoach.php:
'middleware' => ['auth'],
Queue Workers Required
php artisan queue:work
SUPERVISOR or FORK for production.Database Conflicts
mailcoach_* tables.Vue.js Dependencies
npm install
Log Campaign Sends:
Enable logging in config/mailcoach.php:
'log' => [
'enabled' => true,
'channel' => 'single',
],
Check logs at storage/logs/laravel.log.
Test Emails Locally:
Use Laravel’s Mail::fake() to verify emails:
Mail::fake();
Mailcoach::campaigns()->find(1)->sendTo('test@example.com');
Mail::assertSent(MailcoachMail::class);
Clear Caches: After config changes, run:
php artisan config:clear
php artisan view:clear
Custom UI Components
/resources/js/mailcoach/components.API Endpoints
php artisan vendor:publish --tag=mailcoach-routes
routes/mailcoach.php.Event Listeners
CampaignSent):
Mailcoach::campaigns()->on('sent', function ($campaign) {
// Custom logic (e.g., update analytics)
});
Custom Storage
config/mailcoach.php:
'storage' => [
'attachments' => storage_path('app/mailcoach/attachments'),
],
Localization
php artisan vendor:publish --tag=mailcoach-translations
/resources/lang/vendor/mailcoach/ for custom translations.How can I help you explore Laravel packages today?