idf/laravel-real-email-validation

This package is abandoned and no longer maintained. The author suggests using the laravel/framework package instead.

A Laravel rule for performing email addresses validation via regex and DNS checks

1.0.1 2019-08-27 12:20 UTC

This package is auto-updated.

Last update: 2019-12-19 19:41:40 UTC


README

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 hello@team.interaction-design.org instead of using the issue tracker.

Credits

License

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