Download the PHP package magenettic/module-email-validation without Composer
On this page you can find all versions of the php package magenettic/module-email-validation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download magenettic/module-email-validation
More information about magenettic/module-email-validation
Files in magenettic/module-email-validation
Package module-email-validation
Short Description Email validation rules for Magento 2
License MIT
Informations about the package module-email-validation
Magenettic_EmailValidation
Email validation rules module for Magento 2.4.x
Overview
This module adds custom email validation rules for customer registration, allowing merchants to block or allow specific email domains and addresses.
Features
1. Blocked Email Domains (Blacklist)
Rejects customer registrations with emails from specified domains.
Example: If terminator.com is in the blacklist, any email like [email protected] will be rejected.
2. Allowed Email Domains (Whitelist)
Stores a list of allowed email domains.
Example: If company.com is in the whitelist, emails like [email protected] will be allowed.
3. Force Whitelist
When enabled, only emails from domains in the whitelist will be accepted. All other domains will be blocked.
4. Blocked Emails (Blacklist)
Rejects specific email addresses completely.
Example: If [email protected] is in the list, this exact email will be rejected even if the domain is not blocked.
Configuration
Navigate to: Stores > Settings > Configuration > Customers > Customer Configuration > Email Validation
| Setting | Description |
|---|---|
| Enable Email Validation | Enable/disable the module |
| Blocked Email Domains | Enter domains one per line (e.g., terminator.com) |
| Allowed Email Domains | Enter allowed domains one per line |
| Force Whitelist | When enabled, only whitelist domains are accepted |
| Blocked Emails | Enter complete emails one per line |
Requirements
- Magento 2.4.x
- PHP 8.2+
Installation
Inform the repository in you composer.json
Run composer installation
`
Run the magento CLI commands
Validation Flow
Examples
Scenario 1: Block a specific domain
Scenario 2: Allow only specific domains
Scenario 3: Block specific email
Testing
Unit Tests
The module includes comprehensive unit tests covering:
- Helper/DataTest.php - Tests for configuration parsing and validation logic
- Plugin/BeforeEmailValidatorPluginTest.php - Tests for email validation plugin
Run Tests
Test Results
Test Coverage
| Component | Tests | Coverage |
|---|---|---|
| Helper\Data | 18 tests | isEnabled, isWhitelistForced, getBlockedDomains, getAllowedDomains, getBlockedEmails, extractDomain, isDomainBlocked, isDomainAllowed, isEmailBlocked |
| Plugin\BeforeEmailValidatorPlugin | 8 tests | beforeCreateAccountWithPasswordHash, beforeCreateAccount |
Module Structure
License
MIT