Skip to content

Filament blocking a disposable email address on the panel registration page

To block disposable emails in Filament, install erag/laravel-disposable-email and add its rule to the email field: TextInput::make('email')->email()->rules(['disposable_email']). Filament runs every field rule through Laravel's validator, so the same line works in resource forms, custom pages and the panel's Register page. The error appears under the field like any other Filament validation message.

This guide uses Filament 5, the current major version. Its form API is the same as Filament 4, so everything here works on both. There is a short note for Filament 3 further down.

The short version ​

  1. Install the package and sync the domain list.
  2. Add ->rules(['disposable_email']) to any Filament email TextInput.
  3. Extend Filament\Auth\Pages\Register and add the rule in getEmailFormComponent().
  4. Point the panel at your class with ->registration(Register::class).
  5. Do the same for EditProfile, so nobody swaps to a burner inbox later.
  6. In resource forms, only run the rule when the email changes.
  7. Change the wording with validationMessages() and test it with Pest.

Install the package ​

bash
composer require erag/laravel-disposable-email
php artisan erag:install-disposable-email
php artisan erag:sync-disposable-email-list

Composer adds the package and Laravel discovers it. The second command publishes config/disposable-email.php. The third downloads the full domain list, more than 136,000 entries, into storage/app/blacklist_file. Before you sync, the package already blocks about 3,750 well-known services from its built-in list. The installation guide covers manual provider registration and Laravel 10.

New burner services appear every week, so schedule the sync in routes/console.php:

php
use Illuminate\Support\Facades\Schedule;

Schedule::command('erag:sync-disposable-email-list')->daily();

There is no Filament plugin to register. The package adds a normal Laravel validation rule called disposable_email, and Filament uses Laravel's validator under the hood.

How do I add disposable email validation to a Filament TextInput? ​

Chain the rule onto the field:

php
use Filament\Forms\Components\TextInput;

TextInput::make('email')
    ->label('Email address')
    ->email()
    ->required()
    ->maxLength(255)
    ->rules(['disposable_email']);

Each method adds one piece:

MethodWhat it checks
email()Sets type="email" on the input and adds Laravel's email rule for the format.
required()The field is not empty.
maxLength(255)It fits in the users.email column.
rules(['disposable_email'])The domain is not a temporary inbox service.

rules() adds to the field's rules. It doesn't replace the ones email() or required() already added. It accepts an array or a pipe string, so ->rules('disposable_email') works too.

Keep email(). The package rule only looks at the domain, so it is not a replacement for the format check. It also blocks subdomains of a listed domain, so inbox.mailinator.com fails the same way mailinator.com does. You can turn that off with block_subdomains in the config.

Type someone@mailinator.com and submit. Filament shows this under the field:

The email address belongs to an unauthorized email provider.

Filament puts the field label into :attribute and lowercases its first letter, which is why the message says "email address".

How do I block disposable emails on the Filament registration page? ​

The panel's built-in Register page has its own email field, so you extend the page and change that one field. You don't have to rebuild the whole form.

Create the Register page class ​

Create app/Filament/Pages/Auth/Register.php:

php
<?php

namespace App\Filament\Pages\Auth;

use Filament\Auth\Pages\Register as BaseRegister;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Component;

class Register extends BaseRegister
{
    protected function getEmailFormComponent(): Component
    {
        /** @var TextInput $email */
        $email = parent::getEmailFormComponent();

        return $email
            ->rules(['disposable_email'])
            ->validationMessages([
                'disposable_email' => 'Please sign up with an email address you plan to keep.',
            ]);
    }
}

parent::getEmailFormComponent() gives you Filament's own field, with its translated label, email(), required(), maxLength(255) and the unique() check against your users table. You add one rule and a friendlier message, and keep everything else. When Filament updates its default field, your page gets those changes too.

The @var line is only for your editor and static analysis. The method's return type is the generic Component, but the object is a TextInput.

Register it in the panel provider ​

Open app/Providers/Filament/AdminPanelProvider.php and pass your class to registration():

php
use App\Filament\Pages\Auth\Register;
use Filament\Panel;

public function panel(Panel $panel): Panel
{
    return $panel
        ->default()
        ->id('admin')
        ->path('admin')
        ->login()
        ->registration(Register::class)
        // ...keep the rest of your panel config
        ;
}

Visit /admin/register and try a burner address. The form stops before any user row is created, because Filament validates the form state before it calls handleRegistration().

On Filament 3? The base class lives at Filament\Pages\Auth\Register, and Component comes from Filament\Forms\Components\Component. The override itself is the same.

If your sign-up flow lives outside Filament, for example in a Livewire or Inertia app with Fortify, use the Laravel guide or the Livewire version instead.

How do I stop users switching to a disposable email on the profile page? ​

Blocking burner inboxes at registration only helps if people can't change to one a minute later. Filament's profile page has the same kind of email field, so override it the same way. Create app/Filament/Pages/Auth/EditProfile.php:

php
<?php

namespace App\Filament\Pages\Auth;

use Filament\Auth\Pages\EditProfile as BaseEditProfile;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Component;
use Illuminate\Database\Eloquent\Model;

class EditProfile extends BaseEditProfile
{
    protected function getEmailFormComponent(): Component
    {
        /** @var TextInput $email */
        $email = parent::getEmailFormComponent();

        return $email->rules(
            ['disposable_email'],
            fn (?Model $record, ?string $state): bool => $state !== $record?->email,
        );
    }
}

Then add ->profile(EditProfile::class) to the panel next to registration().

The second argument to rules() is a condition. Filament injects the current record and the field's state, so the rule only runs when the user actually types a new address. That matters for accounts that signed up before you added the check. Without the condition, someone who already has a burner address could not even change their name, because every save would fail on a field they didn't touch.

If your panel uses ->emailVerification(), Filament also asks users to verify a changed address. The two checks work well together: the rule stops burner inboxes, and verification proves the person can read the inbox they typed.

How do I validate email in a Filament resource form? ​

In a resource, the email field lives in the generated form schema. For a User resource that is app/Filament/Resources/Users/Schemas/UserForm.php:

php
<?php

namespace App\Filament\Resources\Users\Schemas;

use Filament\Forms\Components\TextInput;
use Filament\Schemas\Schema;
use Illuminate\Database\Eloquent\Model;

class UserForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema
            ->components([
                TextInput::make('name')
                    ->required()
                    ->maxLength(255),
                TextInput::make('email')
                    ->email()
                    ->required()
                    ->maxLength(255)
                    ->unique()
                    ->rules(
                        ['disposable_email'],
                        fn (?Model $record, ?string $state): bool => $state !== $record?->email,
                    ),
            ]);
    }
}

On the create page $record is null, so the rule always runs. On the edit page it only runs when the email changed, for the same reason as the profile page. unique() with no arguments checks the resource's table and ignores the record you are editing, which is the default in Filament 4 and 5.

The same pattern fits any model with an email column: customers, leads, invited team members, newsletter subscribers. Sometimes admins need a throwaway account for testing. If that's your team, add the test domain to whitelist in config/disposable-email.php rather than removing the rule. The whitelist docs show the format.

How do I change the Filament validation message? ​

You have three levels, from narrow to wide:

One field. validationMessages() takes rule names as keys, as in the Register example:

php
->validationMessages([
    'disposable_email' => 'Temporary inboxes are not allowed. Please use your work or personal email.',
])

Only the field name. Keep the package wording but change what :attribute says with ->validationAttribute('work email'). The message becomes "The work email belongs to an unauthorized email provider."

The whole app. Publish Laravel's language files with php artisan lang:publish, then add one key to lang/en/validation.php:

php
'disposable_email' => 'Please use a permanent email address.',

Every Filament form, controller and Livewire component that uses the rule picks it up. Add the same key to other language folders to translate it.

Should I use the string rule or the rule object? ​

The package also ships a rule class. All three forms below run the same domain check:

FormExampleGood for
String rule->rules(['disposable_email'])Most Filament fields. Short, and validationMessages() uses the key disposable_email.
Rule object->rules([new DisposableEmailRule()])Code that prefers classes over strings. The message key becomes disposable_email_rule.
Rule with modes->rules([Disposable::rule('rfc', 'dns')])Adding Laravel's RFC or DNS email modes in the same rule.

DisposableEmailRule lives in EragLaravelDisposableEmail\Rules, and the Disposable facade in EragLaravelDisposableEmail\Facades. A DNS mode makes a network lookup on every submit, so only use it where that delay is acceptable. RFC, DNS and MX validation explained walks through each mode.

How do I test it? ​

Filament pages are Livewire components, so Pest's livewire() helper drives them. Create tests/Feature/Filament/RegisterTest.php:

php
<?php

use App\Filament\Pages\Auth\Register;
use App\Models\User;

use function Pest\Livewire\livewire;

it('rejects a disposable email on the register page', function () {
    livewire(Register::class)
        ->fillForm([
            'name' => 'Asha',
            'email' => 'asha@mailinator.com',
            'password' => 'secret-password',
            'passwordConfirmation' => 'secret-password',
        ])
        ->call('register')
        ->assertHasFormErrors(['email']);

    expect(User::where('email', 'asha@mailinator.com')->exists())->toBeFalse();
});

it('registers a user with a normal email address', function () {
    livewire(Register::class)
        ->fillForm([
            'name' => 'Asha',
            'email' => 'asha@example.com',
            'password' => 'secret-password',
            'passwordConfirmation' => 'secret-password',
        ])
        ->call('register')
        ->assertHasNoFormErrors();

    expect(User::where('email', 'asha@example.com')->exists())->toBeTrue();
});

passwordConfirmation is the field name Filament's Register page uses for the second password box. If you have more than one panel, set the right one as current in a beforeEach() so the page knows which panel it belongs to. A resource form test looks the same with the resource's CreateUser page and call('create').

Run it with:

bash
php artisan test --compact --filter=RegisterTest

Common problems and fixes ​

  • "Method Illuminate\Validation\Validator::validateDisposableEmail does not exist." The package's service provider didn't load. Run composer dump-autoload and php artisan package:discover, and check that the package isn't listed under dont-discover in composer.json.
  • A disposable address still passes. Run php artisan erag:sync-disposable-email-list, and make sure the scheduler runs on your server. If you turned on cache_enabled, clear the cache after changing lists. Disposable::check('someone@example.com')->toArray() in php artisan tinker shows whether a domain matched and which list it came from.
  • The rule doesn't run on the Register page. The panel still uses Filament's own page. Check that ->registration() gets your class, not an empty call.
  • Editing an old user fails on the email field. Add the condition from the resource example so the rule only runs when the email changes.
  • A real customer's domain is blocked. Add it to whitelist in the config. The guide to handling false positives covers how to decide.

Frequently asked questions ​

Does Filament have built-in disposable email validation? ​

No. Filament's email() method only checks the format of the address. To block temporary inbox services, add a rule such as disposable_email from erag/laravel-disposable-email with ->rules().

Does it work with Filament 4 and Filament 3? ​

Yes. Filament 4 and 5 share the same form API, so the code here works unchanged. On Filament 3, import the Register page from Filament\Pages\Auth instead of Filament\Auth\Pages. The rule itself works anywhere Laravel's validator runs.

Can I validate the email when the field loses focus? ​

Filament validates on submit by default. A common community pattern is ->live(onBlur: true) with afterStateUpdated() calling $livewire->validateOnly($component->getStatePath()). Each blur is a request to your server, so most panels keep the default and check on submit.

Does the check call an outside API? ​

No. The domain list is stored inside your app, so each check is a local lookup. The only network call is the sync command, which you run on a schedule.

Can Filament block temporary email addresses without a package? ​

Yes. Filament accepts a closure rule, so you can check the domain against your own list:

php
use Closure;
use Illuminate\Support\Str;

TextInput::make('email')
    ->email()
    ->rules([
        fn (): Closure => function (string $attribute, mixed $value, Closure $fail): void {
            $domain = Str::lower(Str::after((string) $value, '@'));

            if (in_array($domain, ['mailinator.com', 'guerrillamail.com', 'yopmail.com'], true)) {
                $fail('Please use a permanent email address.');
            }
        },
    ]);

That works for a handful of domains. The catch is keeping the list current, because new burner services appear all the time and many use subdomains. The package does that part for you: a synced list of more than 136,000 domains, subdomain matching, a whitelist and optional caching.

Is blocking disposable emails enough to stop fake sign-ups? ​

It removes the easiest kind. Bots also use real free mail providers, so combine it with rate limiting, email verification and a honeypot field. Stopping spam registrations in Laravel covers those, and stopping free trial abuse explains the billing side.

Add it to your Filament panel ​

bash
composer require erag/laravel-disposable-email
php artisan erag:install-disposable-email
php artisan erag:sync-disposable-email-list

Then add ->rules(['disposable_email']) to your Register page, profile page and resource forms.

Last updated:

Code samples: MIT License © eramitgupta