PHP code example of enricodias / email-validator

1. Go to this page and download the library: Download enricodias/email-validator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

enricodias / email-validator example snippets


$emailValidator = new \enricodias\EmailValidator\EmailValidator();
$emailValidator->validate('[email protected]');

$emailValidator->isValid();      // false, gmail.co doesn't have valid MX entries
$emailValidator->isDisposable(); // false, gmail.co isn't a known domain for disposable emails
$emailValidator->isAlias();      // true, [email protected] is alias for [email protected]
$emailValidator->didYouMean();   // [email protected]

$MailboxLayer = new \enricodias\EmailValidator\ServiceProviders\MailboxLayer('API_KEY');

$Mailgun = new \enricodias\EmailValidator\ServiceProviders\Mailgun('API_KEY');

$emailValidator->addProvider($MailboxLayer, 'MailboxLayer');
$emailValidator->addProvider($Mailgun); // the name is optional

$emailValidator->validate('[email protected]');

$emailValidator = new \enricodias\EmailValidator\EmailValidator();

$emailValidator->clearProviders(); // remove all providers

$emailValidator->addProvider($CustomServiceProvider, 'My Custom Provider');

$emailValidator->validate('[email protected]');

$emailValidator = \enricodias\EmailValidator\EmailValidator::create()
    ->removeProvider('MailCheck.ai');
    ->addProvider($CustomServiceProvider)
    ->validate('[email protected]');

$emailValidator->clearProviders()
    ->addProvider($Provider1)
    ->addProvider($Provider2)
    ->shuffleProviders()
    ->validate('[email protected]');

$emailValidator = \enricodias\EmailValidator\EmailValidator::create()
    ->addDomains(['*.domain.com'])
    ->validate('[email protected]',);

$emailValidator->isDisposable(); // true