ovarun/laravel-disposable-email-validation
最新稳定版本:v1.0.0
Composer 安装命令:
composer require ovarun/laravel-disposable-email-validation
包简介
Laravel package to detect disposable email addresses using disposable-email-domains list.
README 文档
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
-
Install package:
composer require ovarun/laravel-disposable-email
-
Publish config (optional):
php artisan vendor:publish --tag=config
-
Update blocklist:
php artisan disposable-email:update
-
Use rule in validation:
'email' => ['required', 'email', new NotDisposableEmail],
⚡ Features
- ✅ Auto-discovers in Laravel (no manual provider setup)
- ✅ Configurable
blocklistandallowlist - ✅ 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!
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-03