dossierdata/laravel-email-validator

A more extensive email validator rule than the default provided by Laravel.
12,383 6
Install
composer require dossierdata/laravel-email-validator
Latest Version:4.0.0
PHP:^8.2
License:MIT
Last Updated:Sep 30, 2025
Links: GitHub  ·  Packagist
Maintainer: lucasvdh

A more extensive email validator than the default provided by Laravel.

Laravel Email Validator

Latest Stable Version Build Status Total Downloads StyleCI Software License

The Laravel Email Validator extends the Laravel Validator with the validate_email rule.

How do I install it?

The easiest way is via Composer.

To install the latest version of Laravel Email Validator, run the command below:

composer require dossierdata/laravel-email-validator

Then register the service provider in config/app.php:

'providers' => [
    ...
    Dossierdata\LaravelEmailValidator\ServiceProvider::class,
    Dossierdata\LaravelEmailValidator\BootServiceProvider::class,
],

Requirements

  • Laravel 5.0 and up

How do I use it?

There are currently four different rules that you can choose from:

  • rfc - Validates that the supplied value complies with RFC 5321 and RFC 5322
  • rfc_no_warning - Same as the previous rule but will fail on warning
  • spf:127.0.0.1 - Validate that the domain of the email has a correct SPF record and that the supplied IP-address/range is authorized for this domain
  • dns - Validates that the domain of the email actually exists by checking for an MX or DSN record

Use is as a rule for Validator:

<?php

// Rule without parameters will default to only checking RFC
$validator = \Validator::make([
    'email' => '.incorrect@email.nodomain'
], [
    'email' => 'validate_email',
]);

if ($validator->fails()) {
    dump($validator->errors());
}

// Rule with parameters
$validator = \Validator::make([
    'email' => '.incorrect@email.nodomain'
], [
    'email' => 'validate_email:rfc,spf:127.0.0.1,dns',
]);

if ($validator->fails()) {
    dump($validator->errors());
}

Use via dependency injection:

<?php

$rules = [
    'rfc',
    'spf:127.0.0.1',
    'dns'
];

$emailValidator = app(\Dossierdata\LaravelEmailValidator\Contracts\EmailValidator::class);

if (!$emailValidator->validateValue('.incorrect@email.nodomain', $rules)) {
    dump($emailValidator->errors());
}

Contributing

See the CONTRIBUTING guidelines for this project.

License

The dossierdata/laravel-email-validator is open-sourced software licensed under the MIT license.

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

634,760,849 9,707
laravel/framework

The Laravel Framework.

584,532,650 34,931
laravel/tinker

Powerful REPL for the Laravel framework.

493,838,477 7,443
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

408,553,772 609
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

387,976,821 4,658