Download the PHP package kalimeromk/email-check without Composer
On this page you can find all versions of the php package kalimeromk/email-check. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kalimeromk/email-check
More information about kalimeromk/email-check
Files in kalimeromk/email-check
Package email-check
Short Description An advanced PHP library for email validation with DNS checks and typo suggestions.
License MIT
Informations about the package email-check
PHP Email Check ๐ง
A lightweight PHP library for advanced email address validation. It performs multi-layered checks, including syntax, domain validity (DNS), disposable service detection, and more.
๐ Table of Contents
- Key Features
- Installation
- System Requirements
- Quick Start
- Basic Usage
- Advanced Features
- Pattern Filtering
- Disposable Email Detection
- DNS Cache Configuration
- Mass Email Validation
- Domain Suggestions
- Configuration
- Testing
- API Reference
- Contributing
- License
โจ Key Features
- โ
Format Check: Validates the basic
[email protected]syntax using PHP's filter_var and advanced validation - ๐ Domain Check: Verifies the domain by checking for valid
MXandADNS records - ๐ Advanced Validation: Comprehensive email format validation with length checks and forbidden character detection
- โก DNS Caching: Built-in caching for DNS queries to improve performance
- ๐ก Typo Correction Suggestions: Offers "Did you mean?" suggestions for common typos in domain names
- ๐ซ Disposable Email Detection: Blocks known disposable/temporary email services with auto-updating lists from multiple sources
- ๐ง SMTP Validation: Optional real-time SMTP validation to verify mailbox existence (disabled by default)
- ๐ง Configurable: Customizable DNS servers, timeouts, and validation options
- ๐ฆ Batch Processing: Validate multiple emails at once
- ๐งช Comprehensive Testing: 150+ tests with 500+ assertions covering all functionality
- ๐ Mass Validation: Parallel processing for millions of emails with optimized performance
โ ๏ธ Important Notice & Limitations
Please Note: This package performs a detailed technical analysis of an email address. However, it cannot 100% guarantee that a specific mailbox actually exists or is active. The only definitive way to verify this is by sending an email with a confirmation link.
๐ฆ Installation
Install the package easily via Composer.
โ๏ธ System Requirements
Minimum Requirements
- PHP: 8.1 or higher
- Memory: 256MB RAM
- CPU: 2 cores
- Extensions:
ext-json,ext-mbstring
Recommended for Mass Validation
- PHP: 8.4 or higher
- Memory: 128GB RAM (for 9M+ emails)
- CPU: 40+ cores with hyperthreading (80 threads)
- Storage: RAID 10 SSD for optimal I/O performance
- Extensions:
ext-pcntl(for parallel processing)
๐ Quick Start
๐ Basic Usage
Understanding the Result
The validate() method returns an associative array with the following keys:
| Key | Type | Description |
|---|---|---|
email |
string | The submitted email address. |
is_valid |
bool | true if the email passes all key validations (format and domain). |
domain_valid |
bool | true if the domain has valid MX or A DNS records. |
is_disposable |
bool | true if the email is from a known disposable service. |
pattern_valid |
bool | true if email passes pattern filtering (fast rejection). |
pattern_status |
string | Pattern validation status: passed, rejected, or warning. |
matched_pattern |
string|null | Regex pattern that matched (if rejected), null if passed. |
smtp_valid |
bool|null | true if SMTP validation confirms mailbox exists, false if failed, null if disabled. |
smtp_response |
string|null | SMTP server response (if SMTP validation enabled), null if disabled. |
smtp_status_code |
string|null | Detailed SMTP status code (if SMTP validation enabled), null if disabled. |
timestamp |
string | When the validation was performed. |
Example Output
๐ง Advanced Features
Pattern Filtering
Pattern filtering provides ultra-fast rejection of obviously invalid emails before expensive DNS/SMTP checks:
Pattern Status Values:
passed- Email passed all pattern checksrejected- Email matched an invalid pattern (fast rejection)warning- Email matched a strict pattern (if strict mode enabled)
Common Invalid Patterns Detected:
- Missing @ symbol
- Multiple @ symbols
- Multiple consecutive dots
- Starts/ends with dots or @
- Contains spaces or invalid characters
- Empty local/domain parts
- Emails that are too long
Disposable Email Detection
The library includes an automatic update system for disposable email domains:
Manual Update
Automatic Update (Cron Job)
Monitoring Disposable Domains
DNS Cache Configuration
The CachedDnsValidator provides advanced caching capabilities:
Cache Drivers
File Cache (Default):
Redis Cache:
Cache Telemetry Monitoring
Mass Email Validation
For processing millions of emails efficiently, use the mass validation system:
Basic Mass Validation
Performance Configuration
Monitoring Progress
Performance Statistics
Based on testing with real email data on high-performance servers:
Standard Mode (40 cores, 1GB per process):
- Processing Speed: 8,000-12,000 emails/second
- Memory Usage: ~1GB per process
- CPU Utilization: 100% (all 40 cores)
- Estimated Time: ~15-20 minutes for 9 million emails
Aggressive Mode (80 threads, 2GB per process):
- Processing Speed: 15,000-25,000 emails/second
- Memory Usage: ~2GB per process
- CPU Utilization: 100% (all 80 threads)
- Estimated Time: ~8-12 minutes for 9 million emails
Output Files
The mass validator generates:
valid_emails.json- All valid email addressesinvalid_emails.json- All invalid email addressesstatistics.json- Detailed performance metricsprogress.json- Real-time progress tracking
Example Output
Domain Suggestions
If the basic validation indicates that the domain is invalid, you can use a helper function to offer the user a correction suggestion:
โ๏ธ Configuration
Environment Variables (.env)
Copy the env.example file to .env and configure your settings:
DNS Cache Configuration
Redis Configuration (used when EMAIL_DNS_CACHE_DRIVER=redis)
SMTP Validation Settings
Pattern Filtering Configuration
Programmatic Configuration
The EmailValidator accepts configuration options:
๐งช Testing
The package includes comprehensive test coverage with PHPUnit:
Test Coverage:
- 150+ tests with 500+ assertions
- Email validation (basic and edge cases)
- DNS validation and caching
- Domain suggestion functionality
- Disposable email detection
- Pattern filtering (fast rejection of invalid emails)
- SMTP validation (enabled/disabled states)
- Data source configuration (.env file reading)
- Helper functions
- Error handling and edge cases
๐ API Reference
EmailValidator Class
Constructor
Methods
DisposableEmailDetector Class
Methods
CachedDnsValidator Class
Methods
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
Made with โค๏ธ by KalimeroMK