- How do I integrate FinMail into an existing Laravel project with Filament?
- Run `composer require finity-labs/fin-mail` and execute `php artisan fin-mail:install`. This sets up migrations, config, and locales. If using Filament v4/v5, the package adds a dedicated email template manager panel. Core email-sending logic works standalone even without Filament’s UI.
- Can I use FinMail without Filament? What’s the minimum setup?
- Yes, FinMail’s core email-sending logic (e.g., `TemplateMail` class) works independently of Filament. You’ll need Laravel’s Mail system and a database, but skip the `fin-mail:install` CLI if avoiding Filament. The UI (template editor, logging) requires Filament v4/v5.
- What Laravel versions and Filament versions does FinMail support?
- FinMail supports Laravel 10.x/11.x and Filament v4.x/v5.x. Check the [README](https://github.com/finity-labs/fin-mail) for exact version constraints. The package leverages Filament’s latest APIs, so minor Filament updates may require testing if they change RichEditor or resource systems.
- How does token replacement work? Can I use conditionals or fallbacks?
- Tokens like `{{ user.name }}` are replaced at runtime using Twig-like syntax. Conditionals (`{% if user.is_premium %}`) and fallbacks (`{{ user.name | 'Customer' }}`) are supported. The system parses tokens during email rendering, so missing data triggers fallbacks or errors based on your config.
- Does FinMail support multilingual emails? How do I configure locales?
- Yes, templates are translatable via `spatie/laravel-translatable`. During installation, define supported locales in `config/fin-mail.php`. Locales must be pre-configured, and the RichEditor toolbar includes language selectors for editing. Dynamic user-selected locales require additional logic in your token context.
- How does email logging work? Can I disable it for production?
- FinMail logs every sent email (status, rendered body, attachments) to the `sent_emails` table. Logging is optional via config and can be disabled per-template. For high-volume systems, consider async logging with Laravel queues or archiving old logs to reduce database bloat.
- Can I customize email templates beyond the default themes?
- Absolutely. Use Blade overrides for templates or extend the RichEditor with custom blocks (e.g., tables, accordions). Themes are Tailwind-based and can be modified via `@source` directives in Filament’s CSS. For advanced use cases, subclass `TemplateMail` or override the `render()` method.
- What’s the performance impact of token replacement and versioning?
- Token replacement adds minimal overhead (~10–50ms per email) but scales with template complexity. Versioning stores diffs in the database, so large templates may increase storage. For high-volume systems, queue email sending and batch-process logs to avoid runtime delays.
- How do I migrate existing Mailable classes to FinMail’s `TemplateMail`?
- Replace `Mailable` classes with `TemplateMail` and define tokens in your Filament resource’s `SendEmailAction`. Use the `HasEmailTemplates` trait on models to link templates. For existing Blade templates, convert them to FinMail’s RichEditor format or use Blade overrides.
- Are there alternatives to FinMail for Laravel email templates?
- Alternatives include `spatie/laravel-mailables` (for static templates), `beberlei/mailable-templates` (Blade-based), or `laravel-notification-channels/mail` (for notifications). FinMail stands out by combining Filament’s UI, dynamic tokens, versioning, and logging in a single package, ideal for admin-driven email workflows.