gitmyhub

EmailValidator

PHP ★ 12k updated 1y ago

PHP Email address validator

EmailValidator is a PHP library that checks whether an email address is valid, with pluggable strategies for RFC syntax rules, live DNS lookups, and Unicode spoof detection that you can combine in a single call.

PHPComposersetup: easycomplexity 2/5

EmailValidator is a PHP library for checking whether an email address is valid. Validating email addresses is a common need in PHP applications: registration forms, contact forms, and mailing list sign-ups all benefit from knowing whether the address a user typed is properly formed before attempting to send to it. This library handles that job with a set of independent validation strategies you can pick from and combine.

The core strategy is RFC validation, which checks that an address follows the format rules defined in the email standards (RFC 5321, 5322, 6530, 6531, and 6532). These RFCs are the technical specifications that define how email addresses are supposed to be structured. A stricter variant called NoRFCWarningsValidation treats even minor deviations from those standards as failures rather than just warnings. A DNS check validation queries the internet to confirm there are actual mail server records for the address domain, which tells you the domain can receive mail, though it does not confirm the specific address exists. A spoof check looks for mixed Unicode characters that could be used to make one email address look visually like another.

All of these strategies can be combined using the MultipleValidationWithAnd class, which runs each check in sequence and only returns valid if every one passes. You can also write your own validation by implementing the EmailValidation interface the library provides.

Installation uses Composer, the standard PHP dependency manager. The DNS and spoof checks require the PHP internationalization extension (intl) to be installed on your server. The library is released under the MIT license.

Where it fits