ovarun/laravel-disposable-email-validation

Laravel package to detect disposable email addresses using disposable-email-domains list.

v1.0.0 2025-09-03 08:35 UTC

This package is auto-updated.

Last update: 2025-09-04 08:07:59 UTC


README

A Laravel package to detect and block disposable email addresses using the disposable-email-domains list.
Supports blocklist (domains to block) and allowlist (domains to allow), with auto-sync from GitHub.

πŸ“¦ Installation

Install via Composer:

composer require ovarun/laravel-disposable-email

The package uses Laravel Package Auto-Discovery, so you don’t need to register the service provider manually.

βš™οΈ Configuration

Publish the config file:

php artisan vendor:publish --tag=config

This will create config/disposable-email.php:

<?php

return [

    'blocklist' => [
        'mailinator.com',
        '10minutemail.com',
        'guerrillamail.com',
    ],

    'allowlist' => [
        'gmail.com',
        'yahoo.com',
        'hotmail.com',
        'outlook.com',
    ],

];
  • Blocklist β†’ Domains that should be blocked.
  • Allowlist β†’ Domains that are explicitly allowed, even if normally considered disposable.

πŸ”„ Updating Blocklist

This package includes an Artisan command to sync the latest blocklist from GitHub:

php artisan disposable-email:update

The synced list is stored at:

storage/app/disposable-email-blocklist.json

βœ… Synced domains + your custom config('disposable-email.blocklist') will be merged together.
βœ… allowlist always takes priority over blocklist.

πŸ›  Usage

Validation Rule

Use the built-in rule in your FormRequest or controller:

use Ovarun\DisposableEmail\Rules\NotDisposableEmail;

$request->validate([
    'email' => ['required', 'email', new NotDisposableEmail],
]);

If the email domain is blocked, the validation will fail with:

Disposable or blocked email addresses are not allowed.

Standalone Check

You can also use the validator class directly:

use Ovarun\DisposableEmail\DisposableEmailValidator;

$validator = new DisposableEmailValidator();

if ($validator->isDisposable('test@mailinator.com')) {
    // Handle blocked email
}

⏱ Optional: Scheduler

To keep your blocklist always up-to-date, schedule the update command in app/Console/Kernel.php:

protected function schedule(Schedule $schedule)
{
    $schedule->command('disposable-email:update')->weekly();
}

πŸ“ Example Workflow

  1. Install package:

    composer require ovarun/laravel-disposable-email
  2. Publish config (optional):

    php artisan vendor:publish --tag=config
  3. Update blocklist:

    php artisan disposable-email:update
  4. Use rule in validation:

    'email' => ['required', 'email', new NotDisposableEmail],

⚑ Features

  • βœ… Auto-discovers in Laravel (no manual provider setup)
  • βœ… Configurable blocklist and allowlist
  • βœ… Artisan command to sync latest domains from GitHub
  • βœ… Validation rule for easy integration
  • βœ… Standalone class for custom usage

πŸ“„ License

MIT License.

πŸ”₯ Ready to keep disposable emails out of your app!