idf / laravel-real-email-validation
A Laravel rule for performing email addresses validation via regex and DNS checks
Installs: 6 681
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 5
Forks: 0
Open Issues: 0
Requires
- php: >=7.1
- egulias/email-validator: ^2.1.11
- illuminate/validation: ^5.8
- symfony/polyfill-intl-idn: ^1.12
Requires (Dev)
- orchestra/testbench: *
- phpunit/phpunit: ^7.0 || ^8.0
This package is auto-updated.
Last update: 2019-12-19 19:41:40 UTC
README
⚠️ This feature is available in Laravel from v5.8.33 (see PR) and thus this package is deprecated. By default, this package uses
['html5', 'rfc', 'host']
validation rules, you can replace it by['email:rfc,dns']
. Unfortunately, Laravel doesn't providehtml5
validation. Read more about Laravel email validation.
Laravel has a good email
validation rule, but it can miss some invalid email addresses.
This packages aims to cover more cases.
Installation
You can install the package via composer:
composer require idf/laravel-real-email-validation
The package will automatically register itself.
Translations
If you wish to edit the package translations, you can run the following command to publish them into your resources/lang
folder
php artisan vendor:publish --provider="IDF\RealEmailValidation\ServiceProvider"
Usage
$this->validate($request, [ 'email' => ['required', 'email', new RealEmail()], ]);
By default it uses the following checks: html5
, rfc
, host
, but you can define your set:
// checks without network requests new RealEmail(['html5', 'rfc'])
html5
: Uses regex pattern for rules defined by WHATWG. Browsers use it forinput[type="email"]
.rfc
: Strict RFC validation. Check against RFC 5321, 5322, 6530, 6531, 6532, treats warnings as errors.host
: Checks DNS Records for the host extracted from email address. Uses network.mx
: Check DNS Records for MX type only. ⚠️ This option is not reliable because it depends on the network conditions and some valid servers refuse to respond to those requests.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email hello@team.interaction-design.org instead of using the issue tracker.
Credits
- All Contributors
- Symfony validation (for inspiration)
License
The MIT License (MIT). Please see License File for more information.