Mails plugin screenshot
Dark mode ready
Multilingual support
Supports v5.x

Mails by Backstage

Community

Backstage Mails can collect and show everything you might want to track and log about the e-mails that has been sent by your Laravel app.

Tags: Analytics Developer Tool
Supported versions:
5.x 4.x 3.x
Backstage avatar Author: Backstage

Package health

Automated checks of this plugin's Composer package

90 / 100
Security 83
Maintenance 100
Ecosystem 100
15 checks
  • Passed: GitHub Actions pinned to SHA
  • Skipped: GitLab CI includes pinned to SHA
  • Passed: Open security advisories
  • Warning: Dependabot PR responsiveness — Stale Dependabot PRs: oldest general PR is 89 days old.
  • Skipped: Renovate MR responsiveness
  • Warning: Dependabot or Renovate configured — Updater does not cover the JavaScript ecosystem, which has a committed lockfile.
  • Passed: Dependency update cooldown configured
  • Passed: Provides a security policy
  • Passed: Abandoned or archived — No consulted source marks the package abandoned (packagist, github).
  • Passed: Commit and release recency — Active: last commit 2 days ago; last release 26 days ago.
  • Passed: composer.lock not committed by library — composer.lock is absent from the released dist archive.
  • Passed: Dist archive is lean
  • Skipped: Current Laravel version supported
  • Passed: Current PHP version supported — Constraint ^8.2 supports current PHP 8.5.
  • Skipped: Current Symfony version supported
Third-party plugin. This is built by the community, not the Filament team. Filament does not review, endorse, or vet the security of plugins outside the filament/ namespace. Review the source and install at your own risk. Found malware or an unresolved security issue the author won't address? Report it .
Powered by Plumb Last scanned 10 hours ago

Documentation

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

#Nice to meet you, we're Backstage

Hi! We are a web development agency from Nijmegen in the Netherlands and we use Laravel for everything: advanced websites with a lot of bells and whistles and large web applications.

#About the package

Mails can collect everything you might want to track about the mails that has been sent by your Filament app. Common use cases are provided in this package:

  • Log all sent emails with only specific attributes
  • View all sent emails in the browser using the viewer
  • Collect feedback about the delivery from email providers using webhooks
  • Get automatically notified when email bounces
  • Prune logging of emails periodically
  • Resend logged email to same or another recipient

#Upcoming features

  • We're currently in the process of writing mail events support for other popular email service providers like Resend, SendGrid, Amazon SES and Mailtrap.
  • Relate emails being send in Laravel directly to Eloquent models, for example the order confirmation email attached to an Order model.

#Why this package

Email as a protocol is very error prone. Succesfull email delivery is not guaranteed in any way, so it is best to monitor your email sending realtime. Using external services like Postmark, Mailgun or Resend email gets better by offering things like logging and delivery feedback, but it still needs your attention and can fail silently but horendously. Therefore we created Laravel Mails that fills in all the gaps.

The package is built on top of Laravel Mails.

Mails

#Installation

You can install the package via composer:

composer require backstage/mails

You can publish and run the migrations with:

php artisan vendor:publish --tag="mails-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="mails-config"

Optionally, you can publish the views using

php artisan vendor:publish --tag="mails-views"

Add the routes to the PanelProvider using the authenticatedRoutes() method, like this:

use Backstage\Mails\Facades\Mails;

public function panel(Panel $panel): Panel
{
    return $panel
        ->authenticatedRoutes(fn () => Mails::routes());
}

The preview and attachment routes also enforce panel authentication and the canManageMails() check themselves, so they remain protected if they are registered with routes(). authenticatedRoutes() is still the recommended registration method.

Then add the plugin to your PanelProvider

use Backstage\Mails\MailsPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugin(MailsPlugin::make());
}

#Security

Using the canManageMails() method, you can define which users have access to the mail resources/pages. Here's a comprehensive example that includes additional logic for flexibility:

use Backstage\Mails\MailsPlugin;
use Illuminate\Support\Facades\Auth;

$panel
    ->plugins([
        MailsPlugin::make()
            ->canManageMails(function () {
                $user = Auth::user();

                // Allow access for users with specific roles
                if ($user->hasRole('admin') || $user->hasRole('supervisor')) {
                    return true;
                }

                // Allow access for users with specific permissions
                if ($user->hasPermissionTo('manage mails')) {
                    return true;
                }

                // Restrict access for all other users
                return false;
            }),
    ]);

This example demonstrates how to combine role-based and permission-based access control, providing a more robust and flexible approach to managing access to mail resources.

The same canManageMails() check protects mail previews and attachment downloads. Attachments can only be downloaded through the mail record they belong to, and previews run in a sandboxed iframe.

#Tenant middleware and route protection

If you want to protect the mail routes with your tenant middleware, add them to authenticatedTenantRoutes():

use Backstage\Mails\MailsPlugin;
use Backstage\Mails\Facades\Mails;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugin(MailsPlugin::make())
        ->authenticatedTenantRoutes(fn () => Mails::routes());
}

Important

For setting up the webhooks to register mail events, please look into the README of Laravel Mails, the underlying package that powers this package.

#Configuration

Sometimes you want to customize the resource, like configuring which users or roles may access the resource. You can do this by overriding the MailResource or EventResource classes in the mails config file. Make sure your custom resource extends the original resource.

return [
    'resources' => [
        'mail' => \App\Filament\Resources\MailResource::class,
        'event' => \App\Filament\Resources\EventResource::class,
        'suppression' => \App\Filament\Resources\SuppressionResource::class
    ],
];

#Features and screenshots

#List with all sent emails and statistics

The package provides a clear overview of all emails, including statistics and the ability to filter the data. Mails

#Resending emails

You can resend emails to the same or another recipient(s). This is useful when your email has bounced and you want to resend it. Mails

#Information

You can view all relevant information about the email, such as the subject, the body, the attachments, the from address, the to address(es), the cc address(es), the bcc address(es), the reply to address, metadata and much more. Mails Mails Mails Mails

#Preview email

The package provides a preview of the email. This is useful to quickly check if the email is correct. Mails

We also provide the raw HTML and plain text of the email. Mails

#Events

The package also logs all events that are fired when an email is sent. This is useful to track the email sending process. Mails Mails

#Testing

composer test

#Changelog

Please see CHANGELOG for more information on what has changed recently.

#Contributing

Please see CONTRIBUTING for details.

#Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

#Credits

#License

The MIT License (MIT). Please see License File for more information.

The author

Backstage avatar Author: Backstage

Backstage is a collection of well crafted Laravel packages and Filament plugins, for building the modern web. Everything is developed within our Dutch Digital Agency called UX.

Plugins
1
Stars
23