Giter Site home page Giter Site logo

emailchecker's Introduction

EmailChecker

Build Status

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

To detect invalid emails, it provides a built-in database of 450+ 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:~0.1"

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('[email protected]');     // true
$checker->isValid('[email protected]'); // 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('[email protected]'); // true
$checker->isValid('[email protected]'); // 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 licensed under the MIT License โ€” see the LICENSE file for details

emailchecker's People

Contributors

mattketmo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.