elliotjreed / disposable-emails-filter
A PHP package for determining whether an email address is from a disposable / temporary email address provider.
Installs: 198 782
Dependents: 0
Suggesters: 0
Security: 0
Stars: 26
Watchers: 3
Forks: 8
Open Issues: 5
Type:package
Requires
- php: ^8.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.64
- phpunit/phpunit: ^11.4
- roave/security-advisories: dev-master
- squizlabs/php_codesniffer: ^3.10
- dev-master
- 5.0.1
- 5.0.0
- 4.0.20
- 4.0.19
- 4.0.18
- 4.0.17
- 4.0.16
- 4.0.15
- 4.0.14
- 4.0.13
- 4.0.12
- 4.0.11
- 4.0.10
- 4.0.9
- 4.0.8
- 4.0.7
- 4.0.6
- 4.0.5
- 4.0.4
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 3.4.15
- 3.4.14
- 3.4.13
- 3.4.12
- 3.4.11
- 3.4.10
- 3.4.9
- 3.4.8
- 3.4.7
- 3.4.6
- 3.4.5
- 3.4.4
- 3.4.3
- 3.4.2
- 3.4.1
- 3.4.0
- 3.3.10
- 3.3.9
- 3.3.8
- 3.3.7
- 3.3.6
- 3.3.5
- 3.3.4
- 3.3.3
- 3.3.2
- 3.3.1
- 3.3.0
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.8
- 3.1.7
- 3.1.6
- 3.1.5
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.13
- 3.0.12
- 3.0.11
- 3.0.10
- 3.0.9
- 3.0.8
- 3.0.7
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.2.1
- 1.2.0
- 1.1.1
- 1.1.0
This package is auto-updated.
Last update: 2024-10-30 12:38:51 UTC
README
Disposable / Temporary Email Address Filter
This package provides a method for determining whether an email address is a disposable / temporary email address.
All credit to the maintaining of the list of disposable / temporary email addresses goes to github.com/disposable-email-domains/disposable-email-domains.
This project and it's maintainer(s) do not discourage the use of such disposable / temporary email addresses, but simply allows for the detection of such.
Installation
PHP 8.2 or above is required. If PHP 8.1 is required please use version 4. If PHP 7.4 to 8.0 is required please use version 3.
To install via Composer:
composer require elliotjreed/disposable-emails-filter
Usage
Check if the email address is in the temporary domain list
The checker / filter can either be used via a static or non-static means:
<?php require 'vendor/autoload.php'; use ElliotJReed\DisposableEmail\Email; if ((new Email())->isDisposable('email@temporarymailaddress.com')) { echo 'This is a disposable / temporary email address'; }
or
<?php require 'vendor/autoload.php'; use ElliotJReed\DisposableEmail\DisposableEmail; if (DisposableEmail::isDisposable('email@temporarymailaddress.com')) { echo 'This is a disposable / temporary email address'; }
List all domains in the temporary email domain list
The lister can either be used via a static or non-static means:
<?php require 'vendor/autoload.php'; use ElliotJReed\DisposableEmail\Email; foreach ((new Email())->getDomainList() as $domain) { echo $domain . PHP_EOL; }
or
<?php require 'vendor/autoload.php'; use ElliotJReed\DisposableEmail\DisposableEmail; foreach (DisposableEmail::getDomainList() as $domain) { echo $domain . PHP_EOL; }
If an invalid email address is provided then an InvalidEmailException
is thrown, so it is advisable to check that the email address is valid first. For example:
<?php require 'vendor/autoload.php'; use ElliotJReed\DisposableEmail\Email; $email = 'not-a-real-email-address#example.net'; if (filter_var($email, FILTER_VALIDATE_EMAIL)) { if ((new Email())->isDisposable($email)) { echo 'This is a disposable / temporary email address'; } } else { echo 'This is not a valid email address'; }
Would output:
This is not a valid email address
You can also provide your own custom domain list in a new line separated plain-text file, for example:
example.com
example.net
Then passing the file location into the constructor:
<?php require 'vendor/autoload.php'; use ElliotJReed\DisposableEmail\Email; new Email('/path/to/custom/list.txt');
If an invalid list is provided then an InvalidDomainListException
is thrown.
Getting Started with this Repository
PHP 7.4 or above and Composer is expected to be installed on our system.
Installing Composer
For instructions on how to install Composer visit getcomposer.org.
Installing the Package
composer require elliotjreed/disposable-emails-filter
Installing for Development
After cloning this repository, change into the newly created directory and run
composer install
or if you have installed Composer locally
php composer.phar install
This will install all dependencies needed for the project.
Running the Tests
All tests can be run by executing
composer run-script test
phpunit
will automatically find all tests inside the test
directory and run them based on the configuration in the phpunit.xml
file.
Built With
License
This project is licensed under the MIT License - see the LICENCE file for details.