DEV Community

Er Amit Gupta
Er Amit Gupta

Posted on

🚫 Stop Disposable Emails in Laravel: The Ultimate `laravel-disposable-email` Guide

Are you tired of spam or temporary emails like tempmail.com, 10minutemail.com, or mailinator.com messing up your Laravel application?

Let me introduce you to laravel-disposable-email – a lightweight yet powerful Laravel package that detects and blocks disposable email addresses using validation rules, runtime checks, Blade directives, and more.

βœ… Already includes over 106,000+ disposable email domains – updated regularly!


πŸ” Why Block Disposable Emails in Laravel?

Disposable or temporary email services are used to:

  • Bypass email verification
  • Spam your app with fake signups
  • Skew analytics and user data
  • Abuse trial-based services or coupons

By using this package, you can keep your user base clean and your analytics real.


βš™οΈ Key Features

  • βœ… 106,000+ disposable email domains included
  • 🧠 Smart validation rule (new DisposableEmailRule())
  • 🧩 Blade directive: @disposableEmail(...)
  • πŸ’‘ Runtime check using helper or facade
  • ⚑ Optional cache support for high-performance
  • πŸ” Auto-sync with open-source blocklists
  • 🧠 Add your own custom domains without coding
  • πŸ›  Laravel 10, 11, and 12 support

πŸš€ Installation

composer require erag/laravel-disposable-email
Enter fullscreen mode Exit fullscreen mode

Then publish the config and domain file:

php artisan erag:install-disposable-email
Enter fullscreen mode Exit fullscreen mode

βœ… How to Use in Laravel

πŸ”’ 1. Validate in Form Requests

Object Rule:

use EragLaravelDisposableEmail\Rules\DisposableEmailRule;

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

String Rule:

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

⚑ 2. Runtime Check

use DisposableEmail;

if (DisposableEmail::isDisposable('test@10minutemail.com')) {
    // Block or log user
}
Enter fullscreen mode Exit fullscreen mode

🧩 3. Blade Directive

@disposableEmail('fake@mailinator.com')
    <p class="text-red-600">Disposable email detected!</p>
@else
    <p class="text-green-600">Looks good!</p>
@enddisposableEmail
Enter fullscreen mode Exit fullscreen mode

πŸ”„ Sync Disposable Domains

This package fetches updated disposable domain lists from trusted open-source sources like:

Update list manually with:

php artisan erag:sync-disposable-email-list
Enter fullscreen mode Exit fullscreen mode

🧠 Add Your Own Domains (Custom Blacklist)

Just add domain names (one per line) to:

storage/app/blacklist_file/disposable_domains.txt
Enter fullscreen mode Exit fullscreen mode

Example:

fakemail.org
trashbox.io
noemail.net
Enter fullscreen mode Exit fullscreen mode

No commands needed β€” the package automatically reads them.


⚑ Enable Caching (Recommended for Performance)

In config/disposable-email.php, set:

'cache_enabled' => true,
'cache_ttl' => 60, // minutes
Enter fullscreen mode Exit fullscreen mode

Clear cache if needed:

php artisan cache:clear
Enter fullscreen mode Exit fullscreen mode

πŸ’» Compatible With Laravel 10, 11, 12

Whether you’re using Laravel 10, 11, or 12, this package works flawlessly.


πŸ”— GitHub & Packagist


πŸ™Œ Conclusion

If you're serious about stopping fake signups, improving user data quality, and securing your Laravel app, laravel-disposable-email is a must-have.

It’s simple, powerful, and ready to use in minutes. Install today and protect your application like a pro.

πŸ“’ Share this with your Laravel community

If you found this useful, give it a ⭐ on GitHub and share the package with your dev team or community. Every spam-free app makes the web better!

Top comments (0)