mattketmo/email-checker

Throwaway email detection library

Installs: 4 047

Dependents: 0

Stars: 28

Watchers: 4

Forks: 5

Open Issues: 1

Language: PHP

v1.2.0 2015-08-27 09:00 UTC

README

Build status... Code quality... License MIT Packagist

PHP library to check if an email comes from a disposable email provider.

To detect invalid emails, it provides a built-in database of 600+ disposable email providers, but you can also use your own data.

Installation

Via Composer:

composer require mattketmo/email-checker

Usage

Basic use of EmailChecker with built-in throwaway email list:

<?php

require __DIR__.'/vendor/autoload.php';

use EmailChecker\EmailChecker;

$checker = new EmailChecker();

$checker->isValid('foo@bar.org');     // true
$checker->isValid('foo@yopmail.com'); // false

Or using a custom adapter:

<?php

use EmailChecker\EmailChecker;
use EmailChecker\Adapter;

$checker = new EmailChecker(new Adapter\ArrayAdapter(array(
    'foo.org',
    'baz.net'
)));

$checker->isValid('foo@bar.org'); // true
$checker->isValid('foo@baz.net'); // false

You can build your own adapter (to use another database) simply by implementing the AdapterInterface.

Integration with Symfony2

This library also provides a constraint validation for your Symfony2 project:

<?php

use EmailChecker\Constraints as EmailCheckerAssert;
use Symfony\Component\Validator\Constraints as Assert;

class User
{
    /**
     * @Assert\NotBlank
     * @EmailCheckerAssert\NotThrowawayEmail
     */
    protected $email;
}

List of some disposable emails database

License

EmailChecker is released under the MIT License. See the bundled LICENSE file for details.