exs/bulk-email-checker-bundle

This bundle provides an email validation through 'Bulk Email Checker' api.

v3.0.2 2020-11-04 16:14 UTC

This package is auto-updated.

Last update: 2024-04-05 00:03:08 UTC


README

Build Status

Installation

Download the bundle using composer

$ composer require exs/bulk-email-checker-bundle

Enable the bundle

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new EXS\BulkEmailCheckerBundle\EXSBulkEmailCheckerBundle(),
        // ...
    );
}

Configuration

Minimum required configuration

exs_bulk_email_checker:
    api_key: 'YourApiKey'

Complete configuration (default values shown)

exs_bulk_email_checker:
    enabled: true
    pass_on_error: true
    check_mx: false
    api_key: 'YourApiKey'
    api_url: 'https://api-v4.bulkemailchecker.com/?key=#api_key#&email=#email#'
    whitelisted_domains: ['mycompany.tld']
    blacklisted_domains: ['thebadguyscompany.tld']

Usage

Use the "BulkEmailChecker" constraint.

<?php
// On any entity or model class.

use EXS\BulkEmailCheckerBundle\Validator\Constraints as ExsAssert;
// ...

class SomeClass
{
    // ...

    /**
     * @var string
     *
     * @ExsAssert\BulkEmailChecker()
     */
    private $email;
    
    // ...
}

You can also use directly the service called "exs_bulk_email_checker.bulk_email_checker_manager" and it's "validate()" method.

// Dummy example

$email = 'foo@bar.baz';
$manager = $this->container->get('exs_bulk_email_checker.bulk_email_checker_manager');
$valid = $manager->validate($email); // boolean value