erag / laravel-disposable-email
A Laravel package to detect and block disposable email addresses.
Fund package maintenance!
eramitgupta
www.paypal.com/paypalme/teamdevgeek
Installs: 3 503
Dependents: 0
Suggesters: 0
Security: 0
Stars: 123
Watchers: 2
Forks: 8
Open Issues: 0
Requires
- php: >=8.1.0
- guzzlehttp/guzzle: ^7.0
- illuminate/console: ^10.0|^11.0|^12.0
- illuminate/filesystem: ^10.0|^11.0|^12.0
- illuminate/support: ^10.0|^11.0|^12.0
- illuminate/translation: ^10.0|^11.0|^12.0
- illuminate/validation: ^10.0|^11.0|^12.0
- laravel/pint: ^1.13
README
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 fromremote_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