1. Go to this page and download the library: Download coodde/mail-checker 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/ */
coodde / mail-checker example snippets
use Coodde\MailChecker\MailChecker;
use Coodde\MailChecker\Regions;
use Coodde\MailChecker\Exceptions\MailCheckException;
use Coodde\MailChecker\Exceptions\RegionMailCheckException;
$mailChecker = new MailChecker([], [], [Regions::RUSSIA]);
// This will return boolean value
$result = $mailChecker->allowed('[email protected]');
// or
$result = $mailChecker->forbidden('[email protected]');
// Also you can catch exception
try {
$mailChecker->validate('[email protected]');
} catch (RegionMailCheckException $e) {
echo "Forbidden region";
} catch (MailCheckException $e) {
echo "Wrong mail format (not validated before checking)";
} catch (\Exception $e) {
echo "Unhandled exception";
}
use Coodde\MailChecker\MailChecker;
use Coodde\MailChecker\Regions;
use Coodde\MailChecker\Exceptions\MailCheckException;
use Coodde\MailChecker\Exceptions\DomainMailCheckException;
use Coodde\MailChecker\Exceptions\ListingMailCheckException;
use Coodde\MailChecker\Exceptions\RegionMailCheckException;
$mailChecker = new MailChecker([], ['ru', 'mail.by'], []);
// This will return boolean value
$result = $mailChecker->allowed('[email protected]');
// or
$result = $mailChecker->forbidden('[email protected]');
$result = $mailChecker->forbidden('[email protected]');
// Also you can catch exception
try {
$mailChecker->validate('[email protected]');
} catch (DomainMailCheckException $e) {
echo "Forbidden domain";
} catch (MailCheckException $e) {
echo "Wrong mail format (not validated before checking)";
} catch (\Exception $e) {
echo "Unhandled exception";
}
use Coodde\MailChecker\MailChecker;
use Coodde\MailChecker\Regions;
use Coodde\MailChecker\Exceptions\MailCheckException;
use Coodde\MailChecker\Exceptions\ListingMailCheckException;
$mailChecker = new MailChecker([MailChecker::CATEGORY_DANGEROUS, MailChecker::CATEGORY_SUSPICIOUS], [], []);
// This will return boolean value
$result = $mailChecker->allowed('[email protected]');
// or
$result = $mailChecker->forbidden('[email protected]');
// Also you can catch exception
try {
$mailChecker->validate('[email protected]');
} catch (ListingMailCheckException $e) {
echo "Dangerous mail provider";
} catch (MailCheckException $e) {
echo "Wrong mail format (not validated before checking)";
} catch (\Exception $e) {
echo "Unhandled exception";
}
$mailChecker = new MailChecker();
// Forbid countries
$mailChecker->forbidRegions([Regions::RUSSIA]);
// Forbid categories
$mailChecker->forbidCategories([
MailChecker::CATEGORY_PAID,
MailChecker::CATEGORY_TEMPORARY,
]);
// Forbid domains
$mailChecker->forbidDomains(['mail.ru']);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.