定制 ovarun/laravel-disposable-email-validation 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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 banner

Laravel Disposable Email Validator logo 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.0 of 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 .php config file as JSON, which silently failed).
  • DisposableEmailValidator is 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.php into resources/domains/, so php artisan config:cache no longer has to load thousands of domain strings into the config cache on every request.
  • NotDisposableEmail now implements Laravel's Illuminate\Contracts\Validation\ValidationRule and 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 ovarun/laravel-disposable-email-validation 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 15
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 19
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-03