PHPackages                             emailverifier/emailchecker - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. emailverifier/emailchecker

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

emailverifier/emailchecker
==========================

An easy to use, accurate-ish &amp; extensible email validation library for PHP 7+

16PHP

Since Jan 25Pushed 5y ago1 watchersCompare

[ Source](https://github.com/pet2166054/mailchecker)[ Packagist](https://packagist.org/packages/emailverifier/emailchecker)[ RSS](/packages/emailverifier-emailchecker/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![PHP Email Validation Tool](https://camo.githubusercontent.com/378614fa0e3efdefdd126212d0c8a5b031cd10124c379218434e76ed49b3e1e9/687474703a2f2f692e696d6775722e636f6d2f4645486a7162752e706e67)](https://camo.githubusercontent.com/378614fa0e3efdefdd126212d0c8a5b031cd10124c379218434e76ed49b3e1e9/687474703a2f2f692e696d6775722e636f6d2f4645486a7162752e706e67)

[![codecov](https://camo.githubusercontent.com/daaba586a74f5144c6607a5a37e72e157b79d1fe811e1c2fc8825fa4c6941c4a/68747470733a2f2f636f6465636f762e696f2f67682f646176656561726c65792f456d61696c2d56616c69646174696f6e2d546f6f6c2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/daveearley/Email-Validation-Tool/) [![Build Status](https://camo.githubusercontent.com/414480cb5c16323129005be870423b9b2c678900123f68a7ddd3ab1ea1e0b8fc/68747470733a2f2f7472617669732d63692e6f72672f646176656561726c65792f456d61696c2d56616c69646174696f6e2d546f6f6c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/daveearley/Email-Validation-Tool) [![Code Climate](https://camo.githubusercontent.com/36e33abca1f06c62b6ad7250884cd71f79c4583ebd305b59c9aa6062180d452d/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f646176656561726c65792f456d61696c2d56616c69646174696f6e2d546f6f6c2f6261646765732f6770612e737667)](https://codeclimate.com/github/daveearley/Email-Validation-Tool/)

**An extensible email validation library for PHP 7+**

The aim of this library is to offer a more detailed email validation report than simply checking if an email is the valid format, and also to make it possible to easily add custom validations.

Currently this tool checks the following:

ValidationDescriptionMX recordsChecks if the email's domain has valid MX recordsValid formatValidates e-mail addresses against the syntax in RFC 822, with the exceptions that comments and whitespace folding and dotless domain names are not supported (as it uses PHP's [filter\_var()](http://php.net/manual/en/function.filter-var.php)).Email HostChecks if the email's host (e.g gmail.com) is reachableRole/Business Email^Checks if the email is a role/business based email (e.g ).Disposable email provider^Checks if the email is a [disposable email](https://en.wikipedia.org/wiki/Disposable_email_address) (e.g ).Free email provider^Checks if the email is a free email (e.g ).Misspelled Email ^Checks the email for possible typos and returns a suggested correction (e.g  -&gt; ).^ **Data used for these checks can be found [here](https://github.com/daveearley/Email-Validation-Tool/tree/master/src/data)**

Installation
============

[](#installation)

```
composer require emailverifier/emailchecker
```

Usage
=====

[](#usage)

Quick Start
-----------

[](#quick-start)

```
// Include the composer autoloader
require __DIR__ . '/vendor/autoload.php';

$validator = EmailValidation\EmailValidatorFactory::create('dave@gmoil.con');

$jsonResult = $validator->getValidationResults()->asJson();
$arrayResult = $validator->getValidationResults()->asArray();

echo $jsonResult;
```

Expected output:

```
{
"valid_format": true,
"valid_mx_records": false,
"possible_email_correction": "dave@gmail.com",
"free_email_provider": false,
"disposable_email_provider": false,
"role_or_business_email": false,
"valid_host": false
}
```

Adding Custom Validations
-------------------------

[](#adding-custom-validations)

To add a custom validation simply extend the [EmailValidation\\Validations\\Validator](https://github.com/daveearley/Email-Validation-Tool/blob/master/src/Validations/Validator.php) class and implement the **getResultResponse()** and **getValidatorName()** methods. You then register the validation using the **EmailValidation\\EmailValidator-&gt;registerValidator()** method.

### Example code

[](#example-code)

// Validations/GmailValidator.php

```
