Are your Laravel application's analytics being skewed by fake users? Are you tired of "10-minute mail" accounts abusing your free trials?
If you're a Laravel developer, you know the struggle of maintaining a clean user database. Disposable (temporary) emails are the primary tool for spammers and bots, leading to poor email deliverability and wasted resources.
Today, weβre looking at a powerful solution: the Laravel Disposable Email Detection package.
π§ Why Should You Block Disposable Emails?
Disposable emails are temporary inboxes that expire after a short period. While they offer privacy for users, they create several headaches for developers:
- Marketing Waste: You can't reach these users with newsletters or updates.
- Trial Abuse: Users can infinitely sign up for free trials.
- Data Integrity: Your "Total Users" count becomes a meaningless metric.
- Domain Reputation: Sending emails to expired domains can hurt your SMTP sender score.
π Introducing erag/laravel-disposable-email
This package is designed to be a "plug-and-play" solution for Laravel 10, 11, and 12. It comes pre-loaded with a massive blacklist and integrates seamlessly into your existing validation logic.
Key Features:
- π₯ 110,000+ Domains: Massive built-in database of known temporary providers.
- π§ Smart Validation: Add a simple rule to your Form Requests.
- π Auto-Sync: Keep your list updated with remote sources automatically.
- β‘ Zero-Config: Works out of the box but remains fully customizable.
- π§© Blade Support: Includes a custom directive for frontend logic.
π Quick Start Guide
1. Installation
Install the package via Composer:
composer require erag/laravel-disposable-email
2. Setup
Publish the configuration file to customize your blacklist or caching settings:
php artisan erag:install-disposable-email
This creates config/disposable-email.php.
π» How to Use It
Validation in Controllers
The easiest way to use this package is within your validation array. Just add the disposable_email rule:
$request->validate([
'email' => 'required|email|disposable_email',
]);
Runtime Checks
Need to check an email manually in a Job or Service class? Use the Facade:
use DisposableEmail;
if (DisposableEmail::isDisposable('test@tempmail.com')) {
// Take action against the spammer
}
Blade Directive
You can even use it directly in your views to show or hide content:
@disposableEmail('user@trashmail.com')
<p class="text-red-500">Please provide a permanent email address.</p>
@enddisposableEmail
π Keeping the List Fresh
Spammers are constantly creating new domains. This package makes it easy to stay ahead. You can sync the latest domain list with a single command:
php artisan erag:sync-disposable-email-list
You can even add your own custom domains by creating a .txt file in your storage folderβno coding required!
π― Conclusion
A clean database is a healthy database. By integrating Laravel Disposable Email Detection, you ensure that your community is built of real people with real mailboxes.
Ready to clean up your app?
Check out the GitHub Repository and give it a star! β
Top comments (0)