ovarun/laravel-disposable-email-validation 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

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

  1. Install package:

    composer require ovarun/laravel-disposable-email
  2. Publish config (optional):

    php artisan vendor:publish --tag=config
  3. Update blocklist:

    php artisan disposable-email:update
  4. Use rule in validation:

    'email' => ['required', 'email', new NotDisposableEmail],

⚡ Features

  • ✅ Auto-discovers in Laravel (no manual provider setup)
  • ✅ Configurable blocklist and allowlist
  • ✅ 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

GitHub 信息

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

其他信息

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