mattketmo/email-checker

Throwaway email detection library

Installs: 2 691

Dependents: 0

Stars: 23

Watchers: 4

Forks: 3

Open Issues: 1

Language: PHP

v1.0 2014-09-13 16:20 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 550+ disposable email providers, but you can also use your own data.

Note: this library is inspired from FGRibreau/mailchecker, except it only focuses on PHP (and integration with Symfony).

Installation

Via Composer:

composer require "mattketmo/email-checker:~1.0"

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 another 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:

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

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

License

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