| 
<?php
 namespace EmailValidator;
 
 require('../vendor/autoload.php');
 
 $customDisposableEmailList = [
 'example.com',
 ];
 
 $bannedDomainList = [
 'domain.com',
 ];
 
 $customFreeEmailList = [
 'example2.com',
 ];
 
 $testEmailAddresses = [
 '[email protected]',
 '[email protected]',
 '[email protected]',
 '[email protected]',
 '[email protected]',
 '[email protected]',
 '[email protected]',
 '[email protected]',
 '[email protected]',
 '[email protected]',
 '[email protected]',
 '[email protected]',
 '[email protected]',
 '[email protected]',
 ];
 
 $config = [
 'checkMxRecords' => true,
 'checkBannedListedEmail' => true,
 'checkDisposableEmail' => true,
 'checkFreeEmail' => true,
 'bannedList' => $bannedDomainList,
 'disposableList' => $customDisposableEmailList,
 'freeList' => $customFreeEmailList,
 ];
 $emailValidator = new EmailValidator($config);
 
 foreach ($testEmailAddresses as $emailAddress) {
 $emailIsValid = $emailValidator->validate($emailAddress);
 echo  ($emailIsValid) ? 'Email is valid' : $emailValidator->getErrorReason();
 if ($emailValidator->isGmailWithPlusChar()) {
 printf(
 ' (%s is a Gmail account and contains a plus character. Sanitized address: %s)',
 $emailAddress,
 $emailValidator->getGmailAddressWithoutPlus()
 );
 }
 echo PHP_EOL;
 }
 
 |