PHP Classes

How to Use a PHP Email Validation Library that Can Discard Disposable Email Addresses in Laravel Application Forms Using the Package Laravel Active Email: Validate email to reject disposable addresses

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2026-02-05 (1 month ago) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
laravel-active-email 1.0MIT/X Consortium ...8Email, Libraries, Validation, PHP 8
Description 

Author

This package can validate email to reject disposable addresses.

It provides classes to work in a Laravel application to provide a validation rule for email address values entered in forms.

The classes can check if the email addresses are from disposable email provider services.

Innovation Award
PHP Programming Innovation award winner
February 2026
Winner
Many PHP Website applications send email message to users with useful notifications and newsletters.

Some users that do not want to receive email messages from the sites, use temporary email addresses provided by disposable email provider servers to avoid receiving such email messages from the Websites after the user registration.

This circumstance makes Websites waste server CPU and bandwidth to users that do not want to receive those email messages.

This package provides validation classes that can be used in PHP Web applications using Laravel to reject disposable email addresses that users may enter the application forms.

Manuel Lemos
Picture of Victor John Ukam
  Performance   Level  
Name: Victor John Ukam is available for providing paid consulting. Contact Victor John Ukam .
Classes: 2 packages by
Country: United Kingdom
Age: 32
All time rank: Not yet ranked
Week rank: Not yet ranked
Innovation award
Innovation award
Nominee: 2x

Winner: 1x

Instructions

Example

<?php

use Illuminate\Support\Facades\Validator;
use
Veeqtoh\ActiveEmail\Rules\NotBlacklistedEmail;

it('validates that emails are not from blacklisted domains - alias', function () {
   
$rule = ['email' => 'notblacklisted'];

   
// Valid email addresses (not blacklisted).
   
$validEmails = [
       
'user@gmail.com',
       
'user@yahoo.com',
       
'user@customdomain.org',
    ];

    foreach (
$validEmails as $email) {
       
$validator = Validator::make(['email' => $email], $rule);
       
expect($validator->passes())->toBeTrue();
    }

   
// Invalid email addresses (blacklisted domains).
   
$invalidEmails = [
       
'user@mailinator.com',
       
'user@tempmail.com',
       
'user@example.ltd',
       
'user@example.co',
       
'user@example.com.nh',
       
'user@example.co.uk',
    ];

    foreach (
$invalidEmails as $email) {
       
$validator = Validator::make(['email' => $email], $rule);
       
expect($validator->fails())->toBeTrue();
    }
});

it('validates that emails are not from blacklisted domains - class instantiation', function () {
   
$rule = ['email' => [new NotBlacklistedEmail]];

   
// Valid email addresses (not blacklisted).
   
$validEmails = [
       
'user@gmail.com',
       
'user@yahoo.com',
       
'user@customdomain.org',
    ];

    foreach (
$validEmails as $email) {
       
$validator = Validator::make(['email' => $email], $rule);
       
expect($validator->passes())->toBeTrue();
    }

   
// Invalid email addresses (blacklisted domains).
   
$invalidEmails = [
       
'user@mailinator.com',
       
'user@tempmail.com',
       
'user@example.ltd',
       
'user@example.co',
       
'user@example.com.nh',
       
'user@example.co.uk',
    ];

    foreach (
$invalidEmails as $email) {
       
$validator = Validator::make(['email' => $email], $rule);
       
expect($validator->fails())->toBeTrue();
    }
});

it('validates that domains can be whitelisted - class instantiation', function () {
   
$rule = ['email' => [new NotBlacklistedEmail]];

   
// Valid email addresses (not blacklisted).
   
$validEmails = [
       
'user@gmail.com',
       
'user@yahoo.com',
       
'user@customdomain.org',
       
'user@10minutemail.com',
    ];

    foreach (
$validEmails as $email) {
       
$validator = Validator::make(['email' => $email], $rule);
       
expect($validator->passes())->toBeTrue();
    }

   
// Invalid email addresses (blacklisted domains).
   
$invalidEmails = [
       
'user@mailinator.com',
       
'user@tempmail.com',
       
'user@example.ltd',
       
'user@example.co',
       
'user@example.com.nh',
       
'user@example.co.uk',
    ];

    foreach (
$invalidEmails as $email) {
       
$validator = Validator::make(['email' => $email], $rule);
       
expect($validator->fails())->toBeTrue();
    }
});

it('validates that domains can be whitelisted - alias', function () {
   
$rule = ['email' => 'notblacklisted'];

   
// Valid email addresses (not blacklisted).
   
$validEmails = [
       
'user@gmail.com',
       
'user@yahoo.com',
       
'user@customdomain.org',
       
'user@10minutemail.com',
    ];

    foreach (
$validEmails as $email) {
       
$validator = Validator::make(['email' => $email], $rule);
       
expect($validator->passes())->toBeTrue();
    }

   
// Invalid email addresses (blacklisted domains).
   
$invalidEmails = [
       
'user@mailinator.com',
       
'user@tempmail.com',
       
'user@example.ltd',
       
'user@example.co',
       
'user@example.com.nh',
       
'user@example.co.uk',
    ];

    foreach (
$invalidEmails as $email) {
       
$validator = Validator::make(['email' => $email], $rule);
       
expect($validator->fails())->toBeTrue();
    }
});


Details

laravel-active-email

<p align="center"> <a href="https://packagist.org/packages/veeqtoh/laravel-active-email"><img src="https://img.shields.io/packagist/v/veeqtoh/laravel-active-email?style=flat-square" alt="Latest Version on Packagist"></a> <a href="https://packagist.org/packages/veeqtoh/laravel-active-email"><img src="https://img.shields.io/packagist/dt/veeqtoh/laravel-active-email?style=flat-square" alt="Total Downloads"></a> <a href="https://packagist.org/packages/veeqtoh/laravel-active-email"><img src="https://img.shields.io/packagist/php-v/veeqtoh/laravel-active-email?style=flat-square" alt="PHP from Packagist"></a> <a href="https://github.com/veeqtoh/laravel-active-email/blob/master/LICENSE"><img src="https://img.shields.io/github/license/veeqtoh/laravel-active-email?style=flat-square" alt="GitHub license"></a> </p>

Table of Contents

Overview

This package provides a library of disposable domains and adds a validator to Laravel apps to check that a given email address isn't coming from a disposable email service such as Mailinator, Guerillamail, Tempmail considering all their possible wildcards.

Key Features

  • You can add your own preferred domains to the black list.
  • You can white list a domain to bye pass the blacklist. This can be useful in development environment.
  • With strict mode, you can control the strictness of the validator, thereby allowing or preventing domains that are not necessarily disposable, but have been classified as disposable.
  • Case-aware.
  • Wildcard-aware.

Installation

Requirements

The package has been developed and tested to work with the following minimum requirements:

  • PHP 8.x
  • Laravel 10.x and above.

Install the Package

You can install the package via Composer. The service provider is discovered automatically.

composer require veeqtoh/laravel-active-email

Publish the Config

You can then publish the package's config file and update it as you'd prefer:

php artisan vendor:publish --provider="Veeqtoh\ActiveEmail\Providers\ActiveEmailProvider"

Usage

Validator Approach

Add the notblacklisted validator to your email validation rules array (or string) to ensure that the domain for a given email address is not blacklisted. I'd recommend you add it after the email validator to make sure a valid email is passed through:

'emailField' => 'email|notblacklisted',

or

'emailField' => ['email', 'notblacklisted'],

Class Approach

Instantiate the NotBlackListedEmail Class as part of your email validation rules array to ensure that the domain for a given email address is not blacklisted. Again, I'd recommend you add it after the email validator to make sure a valid email is passed through:

use Veeqtoh\ActiveEmail\Rules\NotBlackListedEmail;

'emailField' => ['email', new NotBlackListedEmail()],

Customization

The package is highly customizable from the config file with the following features:

Strict Mode

This value determines the strictness level of this feature. when set to true, domains in the grey list are also blacklisted.

It is turned on by default, but can be set in your .env file as follows:

DISPOSABLE_EMAIL_STRICT_MODE=true,

Black List

This is a list of base domains with or without the TLD that are blacklisted by default. Add a domain to this list to blacklist it.

Grey List

This is a list of base domains with or without the TLD that aren't blacklisted by default except when in strict mode. Add a domain to this list to whitelist it when the feature is not set to strict mode. Ensure that the domain is not on the black list.

White List

This is a list of base domains with or without the TLD that are blacklisted by default but you want them to be bye passed.

Error Message

You may define your preferred error message or leave as is to use the package's.

To Do

There's always something that can be done to improve this package. I'd keep updating this list as I think of them.

  • Crawl the web to grab an updated list of disposable domains.
  • Maybe setup a schedule for it..

Testing

To run the package's unit tests, run the following command:

vendor/bin/pest

Security

If you find any security related issues, please contact me directly at victorjohnukam@gmail.com to report it.

Contribution

If you wish to make any changes or improvements to the package, feel free to make a pull request.

Note: A contribution guide will be added soon.

Changelog

Check the CHANGELOG to get more information about the latest changes.

Upgrading

Check the UPGRADE guide to get more information on how to update this library to newer versions.

License

The MIT License (MIT). Please see License File for more information.

Support Me

If you've found this package useful, please consider sponsoring this project. It will encourage me to keep maintaining it.


  Files folder image Files (26)  
File Role Description
Files folder image.github (3 files, 1 directory)
Files folder imageconfig (1 file)
Files folder imagesrc (1 file, 3 directories)
Files folder imagetests (2 files, 2 directories)
Accessible without login Plain text file .styleci.yml Data Auxiliary data
Accessible without login Plain text file CHANGELOG.md Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpstan.neon Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file testbench.yaml Data Auxiliary data
Accessible without login Plain text file UPGRADE.md Data Auxiliary data

  Files folder image Files (26)  /  .github  
File Role Description
Files folder imageworkflows (2 files)
  Accessible without login Plain text file CODEOWNERS Data Auxiliary data
  Accessible without login Plain text file FUNDING.yml Data Auxiliary data
  Accessible without login Plain text file pull_request_template.md Data Auxiliary data

  Files folder image Files (26)  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file ci-phpstan.yml Data Auxiliary data
  Accessible without login Plain text file ci-tests.yml Data Auxiliary data

  Files folder image Files (26)  /  config  
File Role Description
  Accessible without login Plain text file active-email.php Aux. Configuration script

  Files folder image Files (26)  /  src  
File Role Description
Files folder imageFacades (1 file)
Files folder imageProviders (1 file)
Files folder imageRules (1 file)
  Plain text file DisposableEmail.php Class Class source

  Files folder image Files (26)  /  src  /  Facades  
File Role Description
  Plain text file ActiveEmail.php Class Class source

  Files folder image Files (26)  /  src  /  Providers  
File Role Description
  Plain text file ActiveEmailProvider.php Class Class source

  Files folder image Files (26)  /  src  /  Rules  
File Role Description
  Plain text file NotBlacklistedEmail.php Class Class source

  Files folder image Files (26)  /  tests  
File Role Description
Files folder imageArchitecture (3 files)
Files folder imageUnit (2 files)
  Plain text file Pest.php Class Class source
  Plain text file TestCase.php Class Class source

  Files folder image Files (26)  /  tests  /  Architecture  
File Role Description
  Plain text file ClassesTest.php Class Class source
  Accessible without login Plain text file GlobalsTest.php Example Example script
  Plain text file ProvidersTest.php Class Class source

  Files folder image Files (26)  /  tests  /  Unit  
File Role Description
  Accessible without login Plain text file ActiveEmailTest.php Example Example script
  Plain text file TestCase.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads  
 100%
Total:0
This week:0