Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Fin Mail Laravel Package

finity-labs/fin-mail

FinMail adds an email template manager and composer to Filament. Create dynamic, translatable templates with token/merge-tag replacement, CTA blocks, and versioning. Send from any resource via a reusable action, with full email logging and status tracking.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Filament Integration: Perfect fit for Laravel applications using Filament (v4/v5) as an admin panel. Leverages Filament’s UI components (RichEditor, actions, resources) while adding email-specific functionality.
  • Modular Design: Plugin-based architecture allows selective adoption (e.g., disable themes, logging, or Shield policies). Minimal core dependencies (spatie/laravel-settings, spatie/laravel-translatable).
  • Laravel Ecosystem Alignment: Complements Laravel’s Mail system, Queues, and Events. Integrates with existing Mailable classes via TemplateMail wrapper.
  • Separation of Concerns: UI (template management), logic (token replacement), and delivery (email sending) are decoupled, enabling customization.

Integration Feasibility

  • Low Friction: Single Composer package with fin-mail:install CLI for setup (migrations, config, locales). No manual database schema changes required beyond settings table.
  • Filament Dependency: Requires Filament (v4/v5), which may necessitate adoption if not already in use. However, the package’s admin UI is optional—core email-sending logic works standalone.
  • Queue/Event System: Leverages Laravel’s built-in queues and events, reducing additional infrastructure needs.
  • View Overrides: Supports custom email templates via Blade, allowing alignment with existing UI systems.

Technical Risk

  • Filament Version Lock: Tied to Filament 4/5. Upgrades may require testing if Filament evolves its API (e.g., RichEditor changes).
  • Token System Complexity: Dynamic token replacement ({{ user.name }}, conditionals) adds runtime parsing overhead. Edge cases (e.g., circular references, malformed tokens) may need validation.
  • Translatable Dependencies: spatie/laravel-translatable adds complexity for multilingual setups. Locale management must be pre-configured during install.
  • Editor Customization: RichEditor/Tiptap/TinyMCE integration requires Tailwind CSS alignment. Custom blocks need manual implementation.
  • Logging Overhead: Email logging stores rendered bodies and statuses, which could bloat storage for high-volume systems.

Key Questions

  1. Filament Adoption: Is Filament already in use, or would this require a new admin panel?
  2. Locale Strategy: How many languages are needed? Are locales static or dynamic (e.g., user-selected)?
  3. Performance: Will high email volumes require queue tuning (e.g., batch processing, async logging)?
  4. Customization Needs: Are default templates/themes sufficient, or will extensive UI/UX overrides be needed?
  5. Compliance: Does email logging/storage meet GDPR/retention policies? (Logs are polymorphic but persistent.)
  6. Fallbacks: How should token fallbacks ({{ user.name | 'Customer' }}) handle missing data?
  7. Testing: Are there plans for automated testing of token replacement, conditionals, and edge cases?

Integration Approach

Stack Fit

  • Laravel Core: Works natively with Laravel’s Mail, Queues, and Events. No framework changes required.
  • Filament: Designed for Filament’s resource/action system. Integrates with:
    • Resources: SendEmailAction, SentEmailsRelationManager.
    • Actions: Reusable "Send Email" buttons in tables/headers.
    • UI: RichEditor, custom blocks, and theme previews.
  • Frontend: Tailwind CSS for styling. Custom themes require @source directives in Filament’s CSS.
  • Database: Uses spatie/laravel-settings for config and adds tables for:
    • email_templates (content, versions, locales).
    • sent_emails (logs, statuses, attachments).
    • email_themes (color schemes).

Migration Path

  1. Assessment Phase:
    • Audit existing email templates (Blade/Mailable classes) for migration to FinMail’s token system.
    • Identify Filament resources/actions where SendEmailAction can replace custom logic.
  2. Pilot Phase:
    • Install fin-mail in a staging environment.
    • Migrate 1–2 non-critical email templates to test token replacement and UI workflows.
    • Validate locale support and theme customization.
  3. Full Adoption:
    • Replace custom Mailable classes with TemplateMail.
    • Add HasEmailTemplates trait to relevant models.
    • Integrate SentEmailsRelationManager into resources.
    • Configure events/listeners for analytics or post-send actions.
  4. Optimization:
    • Tune queue workers for high-volume sends.
    • Set up scheduled cleanup for old sent_emails (via fin-mail:cleanup command).
    • Customize RichEditor blocks or themes as needed.

Compatibility

  • Laravel Versions: Tested on Laravel 11–13. PHP 8.2+ required.
  • Filament Versions: Explicit support for v4/v5. May need adjustments for v3 or future versions.
  • Editor Compatibility: Defaults to Filament’s RichEditor; supports Tiptap/TinyMCE via EditorContract.
  • Theme Systems: Works with Filament’s built-in themes or custom CSS. Tailwind classes must align with plugin styles.
  • Existing Templates: Mailable classes can coexist initially, but full migration to TemplateMail unlocks FinMail’s UI features.

Sequencing

  1. Prerequisites:
    • Upgrade Laravel/Filament to supported versions if needed.
    • Resolve dependency conflicts (e.g., phpdocumentor/reflection-docblock).
  2. Installation:
    • Run composer require finity-labs/fin-mail.
    • Execute php artisan fin-mail:install (interactive or non-interactive).
  3. Configuration:
    • Register FinMailPlugin in panel() with desired options (e.g., navigation groups, Shield policies).
    • Publish views if using custom email layouts: php artisan vendor:publish --tag=fin-mail-views.
  4. Template Migration:
    • Convert Blade/Mailable templates to FinMail’s token system.
    • Seed initial templates via fin-mail:seed or manually.
  5. UI Integration:
    • Add SendEmailAction to Filament resources.
    • Attach SentEmailsRelationManager to models using HasEmailTemplates.
  6. Testing:
    • Validate token replacement, conditionals, and fallbacks.
    • Test email sending from UI and programmatically.
    • Verify logging, status tracking, and events.
  7. Deployment:
    • Run migrations (php artisan migrate if not done during install).
    • Monitor queue workers and email delivery.

Operational Impact

Maintenance

  • Package Updates: Monitor finity-labs/fin-mail for Filament compatibility changes. Updates may require:
    • Testing token syntax and editor blocks.
    • Adjusting custom themes or blocks.
  • Dependency Management:
    • spatie/laravel-settings and spatie/laravel-translatable may need updates.
    • Tailwind CSS version alignment for themes.
  • Template Maintenance:
    • Versioning system automates backups, but manual reviews may be needed for deprecated tokens or themes.
    • Localization updates require template edits in all supported locales.
  • Logging Retention: Configure fin-mail:cleanup to purge old sent_emails (default: 1 year).

Support

  • Troubleshooting:
    • Token Errors: Debug with {{ token | 'DEBUG' }} fallbacks or check EmailFailed events.
    • Editor Issues: Clear Filament cache (php artisan filament:cache:clear) or verify Tailwind scans.
    • Queue Stalls: Monitor failed_jobs table and adjust queue workers.
  • User Training:
    • Admin users need training on:
      • Token syntax and merge tags.
      • Template versioning/restoration.
      • CTA block configuration.
    • Developers must understand TemplateMail vs. custom Mailable tradeoffs.
  • Documentation Gaps:
    • Custom block development lacks detailed examples.
    • Event payloads could use clearer type hints in docs.

Scaling

  • Performance:
    • Token Parsing: Linear complexity per email. For high volumes, consider caching parsed templates.
    • Queue Handling: Use mail:work with multiple workers for parallel sends. Monitor jobs table.
    • Database: Index sent_emails(recipient, sent_at) for large logs. Partition tables if needed.
  • Storage:
    • Attachments are stored on disk (configurable). Use cloud storage (S3) for scalability.
    • Email bodies are stored in sent_emails; compress if retention is long-term.
  • Concurrency:
    • Template edits are thread-safe (versioned), but concurrent sends may hit rate limits (e.g., SMTP).
    • Use Laravel’s throttle middleware for API-based sends.

Failure Modes

Failure Point Impact Mitigation
Token Parsing Errors Emails fail silently or render broken. Use EmailFailed
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata