Download the PHP package beeyev/disposable-email-filter-php without Composer
On this page you can find all versions of the php package beeyev/disposable-email-filter-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download beeyev/disposable-email-filter-php
More information about beeyev/disposable-email-filter-php
Files in beeyev/disposable-email-filter-php
Package disposable-email-filter-php
Short Description Disposable (temporary/throwaway/fake) email detection library. Automatically updated every week.
License MIT
Homepage https://github.com/beeyev/disposable-email-filter-php
Informations about the package disposable-email-filter-php
🗑 Disposable email detection
PHP package that detects disposable (temporary/throwaway/fake) email addresses. It is framework-agnostic and has no dependencies, but includes support for Laravel.
It validates email addresses to ensure they are genuine, which is useful for managing account sign-ups and assessing the number of legitimate email addresses in your system.
This tool also helps to avoid communication errors and blocks spam addresses.
🚀 The lookup is superfast O(1)
because disposable email domains are stored locally using a native PHP hash set..
🚡 The list of disposable email domains is regularly updated automatically from trusted external sources.
📦 Installation and Usage examples
[!NOTE] Read below for Laravel specific instructions.
Require this package with composer using the following command:
Basic usage
Simple check if the email address is disposable:
Adding custom disposable(blacklisted) and whitelisted domains:
Note: Whitelisted domains have higher priority than blacklisted domains.
It is also possible to add blacklisted and whitelisted domains using constructor dependency:
Note: You can develop your own filtration logic by creating a custom class that implements the
CustomEmailDomainFilterInterface
Handling exceptions:
If you try to pass empty string or string with invalid email format, an exception will be thrown.
If you expect that email address might be invalid and don't want to wrap the code into try/catch,
you can use isDisposableEmailAddressSafe
method to check if email address is correctly formatted before checking if it's disposable:
Laravel specific usage
This package includes a service provider and form validation rule for Laravel.
Install the package (Laravel)
The package will be automatically registered using Laravel auto-discovery mechanism.
But if you need to do it manually, you can add the following line to the providers
array in the config/app.php
file:
Form validation (Laravel)
Use validation rule not_disposable_email
or object new NotDisposableEmail()
,
to check that specific field does not contain a disposable email address.
[!NOTE] ❗ Place it after the email validator to ensure that only valid emails are processed.
Example:
Using facades (Laravel)
You can use the DisposableEmail
facade to access the DisposableEmailFilter
instance:
Config file and translations (Laravel)
Optionally, you can publish the config file and translations to customize the package behavior:
This command will create a disposable-email-filter.php
config file in the config
directory
and translation files in the lang/vendor/disposable-email-filter
directory.
Updating
Since the list of disposable email domains is regularly updated, it is important to keep the package up to date.
A new PATCH
version of the package is released whenever the list is updated.
These updates are safe and non-breaking, allowing you to update the package via this composer command:
You can run this command every time in CI/CD pipelines before the project is deployed.
Contribution
Feel free to contribute to this project if you want to add new features, improve existing ones, or fix bugs.
To add new disposable domains, you can update the blacklist.txt
file and create a pull request.
Alternatively, you can open an issue with the domains you want to be added to the blacklist or whitelist.
External Sources:
Local blacklist and whitelist are stored in the blacklist.txt and whitelist.txt files.
Issues
Bug reports and feature requests can be submitted on the Github Issue Tracker.
© License
The MIT License (MIT). Please see License File for more information.
If you love this project, please consider giving me a ⭐