1. Go to this page and download the library: Download kalimeromk/email-check 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/ */
kalimeromk / email-check example snippets
KalimeroMK\EmailCheck\EmailValidator;
$validator = new EmailValidator();
$result = $validator->validate('[email protected]');
if ($result['is_valid']) {
echo "Email is valid!";
} else {
echo "Email is invalid: " . implode(', ', $result['errors']);
}
use KalimeroMK\EmailCheck\Validators\CachedDnsValidator;
$cachedValidator = new CachedDnsValidator();
// Perform some validations
$cachedValidator->validateDomain('example.com');
$cachedValidator->validateDomain('google.com');
$cachedValidator->validateDomain('example.com'); // This should be a cache hit
// Get telemetry data
$telemetry = $cachedValidator->getTelemetry();
echo "Cache Hit Rate: " . $telemetry['hit_rate'] . "%\n";
echo "Total Requests: " . $telemetry['total_requests'] . "\n";
echo "Cache Hits: " . $telemetry['hits'] . "\n";
echo "Cache Misses: " . $telemetry['misses'] . "\n";
$userEmail = '[email protected]'; // Email with a typo
$validator = new EmailValidator();
$result = $validator->validate($userEmail);
if (!$result['domain_valid']) {
// If the domain is invalid, try to find a suggestion
$suggestion = suggestDomainCorrection($userEmail);
if ($suggestion) {
echo "Did you mean: " . $suggestion . "?";
// Output: Did you mean: [email protected]?
}
}
$validator = new EmailValidator([
'timeout' => 5, // DNS query timeout in seconds
'dns_servers' => ['8.8.8.8', '1.1.1.1'], // DNS servers to use
'check_mx' => true, // Check MX records
'check_a' => true, // Check A records as fallback
'check_spf' => false, // Check SPF records
'check_dmarc' => false, // Check DMARC records
'use_advanced_validation' => true, // Enable advanced validation
'enable_pattern_filtering' => true, // Enable pattern filtering
'pattern_strict_mode' => false, // Enable strict pattern validation
'check_smtp' => false, // Enable SMTP validation
'smtp_timeout' => 10, // SMTP timeout
'smtp_from_email' => '[email protected]', // SMTP from email
'smtp_from_name' => 'Email Validator', // SMTP from name
]);
public function __construct(array $config = [])
public function validate(string $email): array
public function validateBulk(array $emails): array
public function getConfig(): array
public function setConfig(array $config): void
public function isDisposable(string $email): bool
public function isDisposableDomain(string $domain): bool
public function getDisposableDomains(): array
public function getDomainsMetadata(): array
public function hasExternalData(): bool
public function getDataFilePath(): string
public function validateDomain(string $domain): array
public function checkMXRecords(string $domain): array
public function checkARecords(string $domain): array
public function getCacheStats(): array
public function getTelemetry(): array
public function resetTelemetry(): void
public function clearCache(): bool
bash
# Process a large email list (optimized for 40-core server)
php src/Scripts/mass-email-validator.php emails.json --batch-size=5000 --max-processes=40
bash
# Monitor validation progress in real-time
php src/Scripts/monitor-validation.php src/data/mass_validation_*/progress.json
bash
# Run all tests
./vendor/bin/phpunit
# Run specific test suites
./vendor/bin/phpunit tests/EmailValidatorTest.php
./vendor/bin/phpunit tests/DNSValidatorTest.php
./vendor/bin/phpunit tests/CachedDnsValidatorTest.php
./vendor/bin/phpunit tests/DomainSuggestionTest.php
./vendor/bin/phpunit tests/DisposableEmailDetectorTest.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.