Plugins
Dynamic Mail Manager
Plugin to manage dynamic mailer configurations in the database, enabling flexible email sending based on entity-specific settings.
Panel Builder
Dark theme support
Yes
Multi language support
Yes
Compatible with the latest version
Supported versions: 3.x
Documentation

#Introduction

Filament Dynamic Mail Manager is a Filament plugin that allows you to manage mailer configurations in the database in addition to those defined in the Laravel configuration.

This enables sending emails using dynamic configurations tied, for example, to a user or an entity.

Relation Manager screenshot

#Installation

Before use composer to install this package you need to add this package to your composer.json file :

{
"repositories": [
{
"type": "composer",
"url": "https://filament-dyn-mail-manager.composer.sh"
}
]
}

Once the repository has been added to your composer.json file, you can install this package via composer require command:

To install the plugin, you can use Composer:

composer require yebor974/filament-dyn-mail-manager

You will be prompted to provide your username and password:

Loading composer repositories with package information
Authentication required (filament-dyn-mail-manager.composer.sh):
Username: [licensee-email]
Password: [license-key]

The username will be your email address and the password will be equal to your license key, followed by a colon (:), followed by the domain you are activating. For example:

Loading composer repositories with package information
Authentication required (filament-dyn-mail-manager.composer.sh):
Username: your_email@domain.tld
Password: 8c21df8f-6273-4932-b4ba-8bcc723ef500:domain.tld

#Settings

  • You can publish the config file with:
php artisan vendor:publish --tag="filament-dyn-mail-manager-config"

In config file, you have some default mailers, you can restrict or add mailers with default config keys like this :

'smtp' => [
'transport' => 'smtp',
'url' => null,
'host' => null,
'port' => null,
'encryption' => null,
'username' => null,
'password' => null,
'timeout' => null,
'local_domain' => null,
]

To use some mailers you have to install some packages like symfony/mailgun-mailer symfony/http-client for mailgun. Please refer to the Laravel Mail documentation.

  • You can publish and run the migrations with:
php artisan vendor:publish --tag="filament-dyn-mail-manager-migrations"
php artisan migrate

By default, DynMailManagerMailer Model is used. You can defined yours in config file.

Optionally, you can publish translations files with:

php artisan vendor:publish --tag="filament-dyn-mail-manager-translations"

#Usage

#Register plugin to panel

  1. Register plugin on your(s) panel(s) (this step is optionnal):
use Yebor974\FilamentDynMailManager\DynMailManagerPlugin;
 
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
DynMailManagerPlugin::make()
])
}
  1. Implement the DynMailManagerMailableContract on your mailable Model and implements methods. Example with an Entity model :
use Yebor974\FilamentDynMailManager\Contracts\DynMailManagerMailableContract;
 
class Entity extends Model implements DynMailManagerMailableContract
{
...
}

You can use default HasDynMailManagerMailers trait on your mailable Model;

use Yebor974\FilamentDynMailManager\Contracts\DynMailManagerMailableContract;
use Yebor974\FilamentDynMailManager\Traits\HasDynMailManagerMailers;
 
class Entity extends Model implements DynMailManagerMailableContract
{
use HasDynMailManagerMailers;
}

Or you can define the needed relation dynMailManagerMailers function:

use Yebor974\FilamentDynMailManager\Contracts\DynMailManagerMailableContract;
use Yebor974\FilamentDynMailManager\Traits\HasDynMailManagerMailers;
 
class Entity extends Model implements DynMailManagerMailableContract
{
use HasDynMailManagerMailers;
 
public function dynMailManagerMailers(): MorphMany
{
return $this->morphMany(
config('filament-dyn-mail-manager.models.dynMailManagerMailer'),
'mailable'
);
}
}
  1. On you mailable model resource, you can add the default relation manager to manage custom mailers :
use Yebor974\FilamentDynMailManager\Resources\MailableResource\RelationManagers\DynMailManagerDriversRelationManager;
 
public static function getRelations(): array
{
return [
//...
DynMailManagerDriversRelationManager::make()
];
}

Each created configuration generates a slug that must be used when calling the method to send an email.

#Send email

You have all the Laravel mail system. For example you can :

  • Send from notification system on specific mailer by defining the mailer slug on notification :
public function toMail(object $notifiable): MailMessage
{
return (new MailMessage)
->mailer('{YOUR_SLUG_MAILER}')
//...
}

Example:

use Illuminate\Support\HtmlString;
use Yebor974\FilamentDynMailManager\Models\DynMailManagerMailer
 
class ExampleNotification extends Notification implements ShouldQueue
{
use Queueable;
 
public function __construct(protected DynMailManagerMailer $mailer)
{
$this->afterCommit();
}
 
public function toMail(object $notifiable): MailMessage
{
return (new MailMessage)
->mailer($this->mailer->slug)
//...
}
 
//...
}
  • Send from mail system by defining the slug mailer too :
use Illuminate\Support\Facades\Mail;
 
Mail::mailer('{YOUR_SLUG_MAILER}')->send(...);

if slug is not found in database, the MailManager will try to find config on laravel mails config file.

#Changelog

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

#Security Vulnerabilities / Support

If you discover any security related issues or need support, please email me at contact@julienboyer.re

#License Options

We offer three types of licenses for our plugin:

  1. Annual Single Project License: Access to all features, updates, and support for one year, activatable on three environments (local, staging, production).
  2. Annual Unlimited Projects License: Access to all features, updates, and support for one year, with unlimited environment activations.
  3. Unlimited Access License: Lifetime access to all features, updates, and support, with unlimited environment activations.

For detailed terms and conditions, please see License Options.

#Screenshots

  • Mailers relation on an entity resource

Relation Manager screenshot

you can test your mailer with the action table button Send Test Email Action

Test email mailer action

  • Creation of mailgun configuration

creation screenshot creation mailgun screenshot creation mailgun values screenshot

No-reply values are not mandatory

Julien BOYER

Julien is an IT engineer from Reunion Island, France. He is a Freelancer and has a passion for Laravel and Filament.

3
Plugins
48
Stars
More from this author
Featured Plugins