PHPackages                             nilanjan-k/tempmailblocker - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. nilanjan-k/tempmailblocker

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

nilanjan-k/tempmailblocker
==========================

A Laravel package to detect and block disposable/temporary email addresses during validation.

v1.0.0(1w ago)03↓100%MITPHPPHP ^8.1CI passing

Since May 28Pushed 1w agoCompare

[ Source](https://github.com/nilanjan-k/tempmailblocker)[ Packagist](https://packagist.org/packages/nilanjan-k/tempmailblocker)[ RSS](/packages/nilanjan-k-tempmailblocker/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (5)Versions (2)Used By (0)

nilanjan-k/tempmailblocker
==========================

[](#nilanjan-ktempmailblocker)

A Laravel package to detect and block disposable/temporary email addresses during validation.

[![Latest Version on Packagist](https://camo.githubusercontent.com/d998235ca58fe6cd9724142be78ca8d923142cd67f21e1d1b134b4141febe962/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e696c616e6a616e2d6b2f74656d706d61696c626c6f636b65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nilanjan-k/tempmailblocker)[![Laravel](https://camo.githubusercontent.com/f80d05b56b199d032aa8e5deb4065394f6fc4d9a79db55997533bdfaa470f50e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31302e7825323025374325323031312e7825323025374325323031322e7825323025374325323031332e782d6f72616e67652e7376673f7374796c653d666c61742d737175617265)](https://laravel.com)[![PHP Version Require](https://camo.githubusercontent.com/9665a2da9871d5dfada7fb77fabf2059ec00ad7775fb7379a3fe6f0bae6231c8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6e696c616e6a616e2d6b2f74656d706d61696c626c6f636b65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nilanjan-k/tempmailblocker)[![License](https://camo.githubusercontent.com/2dfa6d2f3a0728956b99df5b526c889bc96516ee4ef3b962555cd327cf8c49ff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6e696c616e6a616e2d6b2f74656d706d61696c626c6f636b65722e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Tests](https://camo.githubusercontent.com/c7b9a071109b9d5584044b64c7a73c7bf4c18900b5ecfcfd3f70bc510c1f87c2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6e696c616e6a616e2d6b2f74656d706d61696c626c6f636b65722f74657374732e796d6c3f6c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/nilanjan-k/tempmailblocker/actions)

---

Requirements
------------

[](#requirements)

DependencyVersionPHP8.1 or higherLaravel10.x, 11.x, 12.x, or 13.xGuzzleHttp7.x---

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require nilanjan-k/tempmailblocker
```

Laravel's auto-discovery will register the service provider and facade automatically.

After installation, seed the domain list from the upstream source:

```
php artisan tempmailblocker:update
```

This command writes the domain list to `storage/tempmailblocker/domains.json`. Until you run it, the package uses the small seed list bundled inside the package itself.

---

Configuration
-------------

[](#configuration)

Publish the configuration file to customise behaviour:

```
php artisan vendor:publish --tag=tempmailblocker-config
```

This creates `config/tempmailblocker.php`. Every key is documented below.

KeyDefaultDescription`storage``"file"`Storage driver: `"file"` reads and JSON-decodes the domain file on each cold start; `"cache"` shares the list via Laravel's cache store (Redis/Memcached); `"opcache"` loads a pre-built PHP hash-map from OPcache shared memory — fastest option for PHP-FPM deployments.`cache_key``"tempmailblocker_domains"`Cache key used when `storage` is `"cache"`.`cache_ttl``1440`Cache lifetime in **minutes** (default: 24 hours). Only used when `storage` is `"cache"`.`domains_path``storage_path('tempmailblocker/domains.json')`Absolute path to the JSON domain list on disk. Written by `tempmailblocker:update`; falls back to the bundled seed list if absent.`opcache_path``storage_path('tempmailblocker/domains.php')`Path to the auto-generated PHP hash-map file used by the `"opcache"` driver. Created automatically by `tempmailblocker:update` when `storage` is `"opcache"`.`source_url`*(disposable-email-domains GitHub raw URL)*Remote source from which `tempmailblocker:update` fetches the latest list. Must be an HTTPS URL.`message``"Disposable or temporary email addresses are not allowed."`Default validation error message.`whitelist``[]`Array of domains that are **always allowed**, even if they appear in the blocked list. Subdomains are also covered (whitelisting `example.com` also allows `sub.example.com`).`blacklist``[]`Array of domains that are **always blocked**, even if they do not appear in the blocked list. Subdomains are also covered.### Choosing a storage driver

[](#choosing-a-storage-driver)

DriverBest forHow it works`"file"`Octane / Swoole, single-server setupsReads `domains_path` once per worker process; the singleton holds it in memory for the worker's lifetime.`"cache"`Horizontally-scaled fleetsStores the domain list in Laravel's configured cache store (Redis, Memcached). One warm-up per cache server instead of per worker.`"opcache"`PHP-FPM + OPcache deployments`tempmailblocker:update` writes a PHP file containing the hash map as a literal `return` statement. OPcache compiles it to bytecode on the first request and serves it from shared memory on every subsequent one — no JSON parsing, no disk I/O after the initial compile.To use the `opcache` driver:

1. Set `'storage' => 'opcache'` in `config/tempmailblocker.php`.
2. Run `php artisan tempmailblocker:update` — this writes both `domains.json` and `domains.php`.
3. Schedule daily updates so the PHP file stays fresh (see [Scheduling automatic updates](#scheduling-automatic-updates)).

---

Usage
-----

[](#usage)

### As a string rule

[](#as-a-string-rule)

```
use Illuminate\Foundation\Http\FormRequest;

class RegisterRequest extends FormRequest
{
    public function rules(): array
    {
        return [
            'email' => ['required', 'email', 'indisposable'],
        ];
    }
}
```

### As a Rule object

[](#as-a-rule-object)

```
use NilanjanK\TempMailBlocker\Rules\Indisposable;

$request->validate([
    'email' => ['required', 'email', new Indisposable()],
]);
```

### With a custom error message

[](#with-a-custom-error-message)

```
use NilanjanK\TempMailBlocker\Rules\Indisposable;

$request->validate([
    'email' => [
        'required',
        'email',
        new Indisposable('Sorry, throwaway email addresses are not accepted.'),
    ],
]);
```

### Via the Facade

[](#via-the-facade)

```
use TempMailBlocker;

if (TempMailBlocker::isDisposable($email)) {
    // handle rejection
}

if (TempMailBlocker::isIndisposable($email)) {
    // proceed normally
}
```

Or with the full facade class path:

```
use NilanjanK\TempMailBlocker\Facades\TempMailBlocker;

TempMailBlocker::isDisposable('user@mailinator.com'); // true
TempMailBlocker::isIndisposable('user@gmail.com');    // true
TempMailBlocker::count();                             // e.g. 19 000+
```

---

Updating the Domain List
------------------------

[](#updating-the-domain-list)

Run this Artisan command to download the latest list from the configured `source_url`:

```
php artisan tempmailblocker:update
```

### Scheduling automatic updates

[](#scheduling-automatic-updates)

**Laravel 11+ (`routes/console.php`):**

```
use Illuminate\Support\Facades\Schedule;

Schedule::command('tempmailblocker:update')->daily();
```

**Laravel 10 and below (`app/Console/Kernel.php`):**

```
protected function schedule(Schedule $schedule): void
{
    $schedule->command('tempmailblocker:update')->daily();
}
```

---

Whitelisting &amp; Blacklisting
-------------------------------

[](#whitelisting--blacklisting)

### Whitelist — always allow a domain

[](#whitelist--always-allow-a-domain)

Add domains to `whitelist` in `config/tempmailblocker.php` to allow them even if they appear in the blocked list:

```
'whitelist' => [
    'my-internal-tool.com',
    'trusted-partner.org',
],
```

### Blacklist — always block a domain

[](#blacklist--always-block-a-domain)

Add domains to `blacklist` to block them even if they are absent from the downloaded list:

```
'blacklist' => [
    'new-sketchy-domain.io',
    'suspicious-provider.net',
],
```

Whitelist takes precedence over blacklist. A domain present in both will be **allowed**.

---

Testing
-------

[](#testing)

```
composer test
```

Or directly:

```
./vendor/bin/phpunit
```

---

Contributing
------------

[](#contributing)

Contributions are welcome. Please open an issue first to discuss what you would like to change, then submit a pull request against the `main` branch. Make sure all tests pass and follow PSR-12 coding standards.

---

License
-------

[](#license)

MIT © Nilanjan K

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance98

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

12d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cc610612a319a5839f68c6e0915408f3d419f084a3616ba38299cdea6f928d62?d=identicon)[nilanjan-k](/maintainers/nilanjan-k)

---

Top Contributors

[![nilanjan-k](https://avatars.githubusercontent.com/u/173082519?v=4)](https://github.com/nilanjan-k "nilanjan-k (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nilanjan-k-tempmailblocker/health.svg)

```
[![Health](https://phpackages.com/badges/nilanjan-k-tempmailblocker/health.svg)](https://phpackages.com/packages/nilanjan-k-tempmailblocker)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.9k](/packages/craftcms-cms)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9732.3M121](/packages/roots-acorn)[wendelladriel/laravel-validated-dto

Data Transfer Objects with validation for Laravel applications

762621.7k17](/packages/wendelladriel-laravel-validated-dto)[sunspikes/clamav-validator

Custom Laravel anti-virus validator for file uploads using ClamAV.

3702.0M5](/packages/sunspikes-clamav-validator)[laravel-validation-rules/credit-card

Validate credit card number, expiration date, cvc

2422.3M6](/packages/laravel-validation-rules-credit-card)[erag/laravel-disposable-email

A Laravel package to detect and block disposable email addresses.

249143.0k](/packages/erag-laravel-disposable-email)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
