lacodix/laravel-scoped-mail-config
Send emails with dynamic, per-scope mailer settings in Laravel. Provide SMTP/from config via any model or class implementing HasMailConfig—ideal for multi-tenancy (e.g., Spatie) or user/team-specific mail configurations.
Architecture Fit
The laravel-scoped-mail-config package (v1.2.0) aligns well with Laravel’s modular architecture, enabling scoped mail configuration (e.g., per-tenant or environment-specific SMTP settings) without polluting the global config. Its design leverages Laravel’s service container and binding mechanisms, ensuring clean integration with existing mail drivers (e.g., swiftmailer, mailgun). The addition of Laravel 12 support suggests adherence to Laravel’s evolving patterns, though the removal of "insights" (likely Laravel Forge/Insights integration) may require manual validation of monitoring alternatives.
Integration Feasibility
laravel/framework v12) and maintains backward compatibility with older versions (no breaking changes noted).mail, ses, or third-party drivers.config() helper and service providers, minimizing custom boilerplate.Technical Risk
config:cache). Test cached environments post-integration.Key Questions
Stack Fit
config/app.php.config/mail.php with scoped overrides, using a convention (e.g., mail.scopes.tenant_id = [...]).Migration Path
config/mail.php and related service providers.composer require lacodix/laravel-scoped-mail-config
php artisan vendor:publish --provider="Lacodix\ScopedMailConfig\ScopedMailConfigServiceProvider"
config/mail.php or a new scoped-mail.php:
'scopes' => [
'tenant_id' => [
'driver' => 'ses',
'host' => env('SES_HOST'),
],
],
ScopedMailConfig::scope('tenant_id', $tenantId);
config:cache and queue workers.Compatibility
Sequencing
Maintenance
Support
FUNDING.yml suggests community support is available.ScopedMailConfig::getScopes() to inspect active configs.mail.php backup for rollback.Scaling
Failure Modes
| Scenario | Impact | Mitigation |
|---|---|---|
| Missing scope | Falls back to global config | Validate scopes in middleware |
| Database timeout | Dynamic scope resolution fails | Cache scopes with TTL |
| Laravel config cache | Stale scoped configs | Clear cache or use config:clear |
| Mail driver misconfig | Emails fail silently | Implement retry logic with logging |
Ramp-Up
Mail::fake() with scoped drivers).How can I help you explore Laravel packages today?