erag/laravel-disposable-email

A Laravel package to detect and block disposable email addresses.

v3.4.0 2025-05-31 16:56 UTC

This package is auto-updated.

Last update: 2025-05-31 17:05:54 UTC


README

Screenshot 2024-10-04 at 10 34 23โ€ฏPM

Packagist License Latest Stable Version Total Downloads

A Laravel package to detect and block disposable (temporary) email addresses during validation or runtime logic.

Already contains 106,580+ disposable email domains! ๐Ÿ”ฅ

โœ… Features

  • ๐Ÿ”ฅ 106,000+ known disposable domains already included
  • ๐Ÿง  Smart validation rule for form requests
  • โš™๏ธ Runtime email checking via helper and facade
  • ๐Ÿงฉ Blade directive support for conditionals
  • ๐ŸŒ Auto-sync with remote domain lists
  • ๐Ÿ“ Add your own custom blacklist with ease
  • ๐Ÿง  Optional caching for performance
  • โšก๏ธ Zero-configuration setup with publishable config
  • โœ… Compatible with Laravel 10, 11, and 12

๐Ÿš€ Installation

composer require erag/laravel-disposable-email

Register the Service Provider

For Laravel (Optional) v11.x, v12.x

Ensure the service provider is registered in your /bootstrap/providers.php file:

use EragLaravelDisposableEmail\LaravelDisposableEmailServiceProvider;

return [
    // ...
    LaravelDisposableEmailServiceProvider::class,
];

For Laravelv v10.x

Ensure the service provider is registered in your config/app.php file:

'providers' => [
    // ...
    EragLaravelDisposableEmail\LaravelDisposableEmailServiceProvider::class,
],

๐Ÿ›  Configuration

Publish the config file:

 php artisan erag:install-disposable-email  

This will create config/disposable-email.php.

โš™ Usage

1. Form Request Validation

โœ… Custom Rule:

use EragLaravelDisposableEmail\Rules\DisposableEmailRule;

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

โœ… String-based Rule:

$request->validate([
    'email' => 'required|email|disposable_email',
]);
$request->validate([
    'email' => ['required', 'email', 'disposable_email'],
]);

2. Direct Runtime Check

use EragLaravelDisposableEmail\Rules\DisposableEmailRule;

if (DisposableEmailRule::isDisposable('test@tempmail.com')) {
    // Do something if email is disposable
}

Or via facade:

use DisposableEmail;

if (DisposableEmail::isDisposable('agedmail.com')) {
    // Do something
}

3. Blade Directive

@disposableEmail('amit@0-mail.com')
    <p class="text-red-600">Disposable email detected!</p>
@else
    <p class="text-green-600">Valid email.</p>
@enddisposableEmail

๐Ÿ”„ Sync From Remote (Optional)

Update the list manually

php artisan erag:sync-disposable-email-list

๐Ÿ”— Config Options (config/disposable-email.php)

return [
    'blacklist_file' => storage_path('app/blacklist_file),

    'remote_url' => [
        'https://raw.githubusercontent.com/disposable/disposable-email-domains/master/domains.txt',
        'https://raw.githubusercontent.com/7c/fakefilter/refs/heads/main/txt/data.txt',
    ],
    
    'cache_enabled' => false,
    'cache_ttl' => 60,
];

โœ… Note: The .txt files from remote_url must follow this format:
Each line should contain only a domain name, like:

0-00.usa.cc
0-30-24.com
0-attorney.com
0-mail.com
00-tv.com
00.msk.ru
00.pe
00000000000.pro
000728.xyz
000777.info
00082cc.com
00082dd.com
00082ss.com

If the file contains anything other than plain domains (like comments or extra data), it may cause parsing issues.

๐Ÿงฉ Add Your Own Disposable Domains

โœ… Want to block additional disposable domains?
You can easily extend the list manually โ€” no coding, no command required!

Step Action
๐Ÿ”น 1 Go to the following path:
storage/app/blacklist_file/
๐Ÿ”น 2 Create or edit this file:
disposable_domains.txt
๐Ÿ”น 3 Add your custom domains like:
abakiss.com
fakemail.org
trashbox.io
(one per line)

๐Ÿ“Œ Important Notes:

  • Each line must contain only the domain name โ€“ no extra symbols, no comments.
  • The package will automatically detect and use the domains from this file.
  • You do not need to run any Artisan command. ๐Ÿง™โ€โ™‚๏ธ

โš™๏ธ Ensure File Path Matches Configuration

Your file path must match the one defined in config/disposable-email.php:

'blacklist_file' => storage_path('app/blacklist_file'),

If the path or filename is different, the package will not load your custom list.

๐Ÿง  Caching Support (Optional)

This package supports optional caching to improve performance, especially when dealing with large domain lists.

๐Ÿ”ง How It Works

  • If enabled, the package will cache the compiled list of disposable domains for faster lookup.
  • This is useful in high-traffic applications where the same list is accessed frequently.

๐Ÿ›  Enable Caching

To enable caching, update the config file config/disposable-email.php:

'cache_enabled' => true,
'cache_ttl' => 60, 

๐Ÿงน Clear Cached List

If you manually update the domain list and want to clear the cache, you can use:

php artisan cache:clear