Download the PHP package nilanjan-k/tempmailblocker without Composer

On this page you can find all versions of the php package nilanjan-k/tempmailblocker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package tempmailblocker

nilanjan-k/tempmailblocker

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

Latest Version on Packagist Laravel PHP Version Require Tests


Requirements

Dependency Version
PHP 8.1 or higher
Laravel 10.x, 11.x, 12.x, or 13.x
GuzzleHttp 7.x

Installation

Install the package via Composer:

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

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

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

Publish the configuration file to customise behaviour:

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

Key Default Description
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

Driver Best for How it works
"file" Octane / Swoole, single-server setups Reads domains_path once per worker process; the singleton holds it in memory for the worker's lifetime.
"cache" Horizontally-scaled fleets Stores 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).

Usage

As a string rule

As a Rule object

With a custom error message

Via the Facade

Or with the full facade class path:


Updating the Domain List

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

Scheduling automatic updates

Laravel 11+ (routes/console.php):

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


Whitelisting & Blacklisting

Whitelist — always allow a domain

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

Blacklist — always block a domain

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

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


Testing

Or directly:


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

MIT © Nilanjan K


All versions of tempmailblocker with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/support Version *
illuminate/validation Version *
guzzlehttp/guzzle Version ^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nilanjan-k/tempmailblocker contains the following files

Loading the files please wait ...