Download the PHP package phporbit/php-email-validator without Composer
On this page you can find all versions of the php package phporbit/php-email-validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download phporbit/php-email-validator
More information about phporbit/php-email-validator
Files in phporbit/php-email-validator
Package php-email-validator
Short Description PHP email validation library to check format, disposable emails, and MX records.
License MIT
Informations about the package php-email-validator
PHPOrbit/php-email-validator
A PHP library for robust email validation. This package checks the email format, detects disposable email domains, and validates MX records to ensure the reliability of email addresses.
Features
- Format Validation: Ensures the email address follows a valid syntax.
- Disposable Email Detection: Identifies temporary or disposable email addresses using an up-to-date blocklist.
- MX Record Validation: Verifies the existence of a mail server for the domain.
- Lightweight: Includes all dependencies and blocklists in the package for offline use.
Installation
Install the package via Composer:
Compatibility
This package is compatible with the following PHP versions:
- PHP 7.4
- PHP 8.0
- PHP 8.1
- PHP 8.2
- PHP 8.3
- PHP 8.4
For other PHP versions, please ensure your project meets the minimum requirements of PHP 7.4 or later.
Usage
Basic Example
Advanced Example with Form Validation
Integrate the validator into a user registration form:
How It Works
-
Email Format Validation:
- The package uses PHP's
filter_var
function to validate the basic format of the email address. - Example:
[email protected]
is valid, buttest@com
is not.
- The package uses PHP's
-
Disposable Email Detection:
- The package checks the domain of the email address against a blocklist of disposable email providers.
- Example:
[email protected]
is marked as disposable.
- MX Record Validation:
- The package uses the
checkdnsrr
function to verify if the email domain has a valid mail exchange (MX) record. - Example:
example.com
with a valid mail server passes validation.
- The package uses the
Blocklist and Allowlist
The package comes with preloaded blocklist and allowlist files located in the data/
directory. These lists are updated regularly to ensure accuracy.
- Blocklist (
blocklist.json
): Contains domains of known disposable email providers. - Allowlist (
allowlist.json
): Contains domains that should always be considered valid, even if they resemble disposable domains.
You can customize these files as needed.
Testing
The package includes PHPUnit tests to verify its functionality. Run the tests using the following command:
Contributing
Contributions are welcome! To contribute:
- Fork the repository.
- Make your changes.
- Submit a pull request.
Please ensure that all new code is covered by tests and adheres to the PSR-12 coding standards.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Author
Changelog
v1.0.2
- Updated blocklist and allowlist files.
- Improved code quality and documentation.
- Added more tests for edge cases.
v1.0.0
- Initial release with support for:
- Email format validation
- Disposable email detection
- MX record validation