https://github.com/zytzagoo/smtp-validate-email
A PHP library for performing email addresses validation via SMTP
https://github.com/zytzagoo/smtp-validate-email
email-validation smtp
Last synced: 3 months ago
JSON representation
A PHP library for performing email addresses validation via SMTP
- Host: GitHub
- URL: https://github.com/zytzagoo/smtp-validate-email
- Owner: zytzagoo
- License: gpl-3.0
- Created: 2009-01-30T15:25:37.000Z (over 16 years ago)
- Default Branch: master
- Last Pushed: 2022-09-12T14:02:38.000Z (about 3 years ago)
- Last Synced: 2024-11-14T12:09:53.125Z (11 months ago)
- Topics: email-validation, smtp
- Language: PHP
- Homepage:
- Size: 156 KB
- Stars: 446
- Watchers: 36
- Forks: 157
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# SMTP\_Validate\_Email
[](https://packagist.org/packages/zytzagoo/smtp-validate-email)
[](LICENSE.txt)

[](https://travis-ci.org/zytzagoo/smtp-validate-email)
[](https://scrutinizer-ci.com/g/zytzagoo/smtp-validate-email/?branch=master)Perform email address validation/verification via SMTP.
The `SMTPValidateEmail\Validator` class retrieves MX records for the email domain and then connects to the
domain's SMTP server to try figuring out if the address really exists.Earlier versions (before 1.0) used the `SMTP_Validate_Email` class name (and did not use namespaces and other now-common PHP features). Care has been taken to keep the old API and migrating old code should be painless. See ["Migrating to 1.0 from older versions"](#migrating-to-1.0-from-older-versions) section. Or just use/download the ancient [0.7 version](https://github.com/zytzagoo/smtp-validate-email/releases/tag/v0.7).
## Features
* Not actually sending the message, gracefully resetting the SMTP session when done
* Command-specific communication timeouts implemented per relevant RFCs
* Catch-all account detection
* Batch mode processing supported
* Logging/debugging support
* No external dependencies
* Covered with unit/functional tests## Installation
Install via [composer](https://getcomposer.org/):
`composer require zytzagoo/smtp-validate-email --update-no-dev`
## Usage examples
### Basic example
```php
debug = true;
$results = $validator->validate();var_dump($results);
// Get log data (log data is always collected)
$log = $validator->getLog();
var_dump($log);
```### Multiple recipients and other details
```php
validate();var_dump($results);
/**
* The `validate()` method accepts the same parameters
* as the constructor, so this is equivalent to the above:
*/
$emails = [
'someone@example.org',
'someone.else@example.com'
];
$sender = 'sender@example.org';
$validator = new SmtpEmailValidator();
$results = $validator->validate($emails, $sender);var_dump($results);
```## Migrating to 1.0 from older versions
Earlier versions used the global `SMTP_Validate_Email` classname.
You can keep using that name in your existing code and still switch to the newer (composer-powered) version by using [aliasing/importing](http://php.net/manual/en/language.namespaces.importing.php) like this:Require the composer package:
`composer require zytzagoo/smtp-validate-email --update-no-dev`
And then in your code:
```php