Utility Class to validate Email address string as well as determine if the Email inbox exists on the mail server by using an SMTP lookup.
For extended usage examples, see test files.
Composer Ready
Available on Packagist: https://packagist.org/packages/rottingham/emailvalidator
Simply import the Emailvalidator.class.php
file into your project if you are not using dependency injection.
require __DIR__ . '/src/com/rottingham/EmailValidator/EmailValidator.class.php';
To validate an Email string, use the EmailValidator::validate(email)
method;
$email = '[email protected]';
$isValid = EmailValidator\EmailValidator::validate($email);
var_dump($isValid);
To determine if the Emai actaully exists on the mail server, use the EmailValidator::exists(email)
method;
$email = '[email protected]';
$exists = EmailValidator\EmailValidator::exists($email);
var_dump($exists);
Note: EmailValidator::exists(url)
calls EmailValidator\SmtpLookup\SmtpLookup::lookup(email)
and requests from the mail server whether or not the address book record exists. This could fail if your IP address and/or mail server have been blacklisted.
You can use the EmailValidator\SmtpLookup.class.php
class seperately by importing it into your project.
require __DIR__ . '/src/com/rottingham/SmtpLookup/SmtpLookup.class.php';