Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

👮‍♀️ A Laravel rule for performing email addresses validation via regex and DNS checks

License

Notifications You must be signed in to change notification settings

InteractionDesignFoundation/laravel-real-email-validation

Repository files navigation

Real email validation for Laravel

Build Status Code coverage Quality Score StyleCI Latest Version on Packagist Total Downloads

⚠️ 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 provide html5 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'])
  1. html5: Uses regex pattern for rules defined by WHATWG. Browsers use it for input[type="email"].
  2. rfc: Strict RFC validation. Check against RFC 5321, 5322, 6530, 6531, 6532, treats warnings as errors.
  3. host: Checks DNS Records for the host extracted from email address. Uses network.
  4. 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 [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

👮‍♀️ A Laravel rule for performing email addresses validation via regex and DNS checks

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages