⚠️ 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.
You can install the package via composer:
composer require idf/laravel-real-email-validation
The package will automatically register itself.
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"
$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.
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
- All Contributors
- Symfony validation (for inspiration)
The MIT License (MIT). Please see License File for more information.