ovarun/laravel-disposable-email-validation
Composer 安装命令:
composer require ovarun/laravel-disposable-email-validation
包简介
Laravel package to detect disposable email addresses using disposable-email-domains list.
README 文档
README
Laravel Disposable Email Validator
A Laravel package to detect and block disposable email addresses, seeded from the disposable-email-domains project. Supports a blocklist and an allowlist, with an Artisan command to sync both from upstream.
Requires Laravel 12+ and PHP 8.2+. For older Laravel versions, use
^1.0of this package.
📦 Installation
composer require ovarun/laravel-disposable-email-validation
The package uses Laravel Package Auto-Discovery, so you don't need to register the service provider manually.
⚙️ Configuration
Publish the config file (optional — sensible defaults are used otherwise):
php artisan vendor:publish --tag=config
This creates config/disposable-email.php:
<?php return [ // Extra domains to block, on top of the bundled + synced lists. 'blocklist' => [], // Domains that are always allowed, even if blocked elsewhere. Wins over blocklist. 'allowlist' => [], 'sync' => [ 'blocklist_url' => 'https://raw.githubusercontent.com/disposable-email-domains/disposable-email-domains/master/disposable_email_blocklist.conf', 'allowlist_url' => 'https://raw.githubusercontent.com/disposable-email-domains/disposable-email-domains/master/allowlist.conf', 'timeout' => 10, 'minimum_entries' => 100, 'disk' => 'local', ], ];
The package ships with a bundled snapshot of the upstream blocklist/allowlist (several thousand domains), so it works out of the box with no configuration and no network access required. The blocklist/allowlist config keys are only for your own custom additions.
🔄 Updating the Lists
Sync the latest blocklist and allowlist from upstream:
php artisan disposable-email:update
This fetches both lists over HTTP, validates that the response looks like a real domain list (rejecting anything with fewer than sync.minimum_entries valid-looking domains, to avoid corrupting your data with a bad response), and writes them atomically to:
storage/app/disposable-email/blocklist.json
storage/app/disposable-email/allowlist.json
These synced files are merged with the bundled defaults and your custom config entries every time the validator runs. Allowlist always wins.
Optional: schedule it
// routes/console.php or app/Console/Kernel.php Schedule::command('disposable-email:update')->weekly();
🛠 Usage
Validation Rule
use Ovarun\DisposableEmail\Rules\NotDisposableEmail; $request->validate([ 'email' => ['required', 'email', new NotDisposableEmail()], ]);
If the email domain is blocked, validation fails with:
Disposable or blocked email addresses are not allowed.
Standalone Check
use Ovarun\DisposableEmail\DisposableEmailValidator; $validator = app(DisposableEmailValidator::class); if ($validator->isDisposable('test@mailinator.com')) { // Handle blocked email }
DisposableEmailValidator is registered as a container singleton, so the (potentially large) merged domain list is only built once per request/worker instead of on every validation call — resolve it via the container rather than new-ing it directly where possible.
⚡ What changed in v2
- Fixed the sync command: it now correctly pulls plain-text domain lists from the real upstream repository (previously it fetched this package's own
.phpconfig file as JSON, which silently failed). DisposableEmailValidatoris bound as a container singleton and uses O(1) hash-map lookups instead of scanning the list linearly on every call.- The bundled domain lists moved out of
config/disposable-email.phpintoresources/domains/, sophp artisan config:cacheno longer has to load thousands of domain strings into the config cache on every request. NotDisposableEmailnow implements Laravel'sIlluminate\Contracts\Validation\ValidationRuleand safely rejects non-string input instead of throwing.- The update command validates and atomically writes synced lists, with a request timeout and a sanity check against truncated/empty responses.
- Dropped support for Laravel < 12 and PHP < 8.2.
📄 License
MIT License.
ovarun/laravel-disposable-email-validation 适用场景与选型建议
ovarun/laravel-disposable-email-validation 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 09 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「email」 「validation」 「spam」 「laravel」 「disposable-email」 「temporary-email」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ovarun/laravel-disposable-email-validation 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ovarun/laravel-disposable-email-validation 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ovarun/laravel-disposable-email-validation 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Simple captcha generator
reCAPTCHA library
Client library for reCAPTCHA with proxy support, a free service that protects websites from spam and abuse.
Adds request-parameter validation to the SLIM 3.x PHP framework
Extensible library for building notifications and sending them via different delivery channels.
Email+ extends Kirby's email capabilities by adding support for multiple email services using the same Kirby email API.
统计信息
- 总下载量: 15
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-03
