Integrations
Laravel integration
A Laravel validation rule, ValidEmail, fails an address that cannot receive email in any form request or Validator::make call. It is built on our PHP client library, checks each address once, and lets a real person through when the API cannot answer in time.
- Status: Setup guide
- One rule after Laravel’s email rule
composer config repositories.email-validation-laravel artifact ./packages
composer require email-validation/laravel:^0.1
# .env
EV_API_KEY=your-api-key
# in your validation rules
'email' => ['bail', 'required', 'email', new ValidEmail()],
'email' => 'bail|required|email|valid_email:invalid,disposable',At a glance.
- Status
- Setup guide. Not listed on a marketplace yet: you set it up yourself in a few steps, below and in the full guide.
- For
- Laravel developers who want sign-up, checkout and contact forms to refuse addresses that cannot receive mail, without a slow or failed check ever blocking a real person.
- You need
- Laravel 10 or newer, PHP 8.1 or newer, Composer, and an API key made for it, with a daily credit cap, with the permission Validate addresses, set as
EV_API_KEYin.env. - Costs
- 1 credit = 1 validated address, as with any API request. Free: unknown results, API errors, malformed addresses and test addresses on sandbox.email-validation.org.
- Full guide
- Read the full setup guide
Typical uses.
Block bad sign-ups
Add the rule after email on a sign-up form: an address with no mailbox fails the field with a message, and the person can fix a typo and send the form again.
Choose what fails
Only
invalidfails by default. PassfailOn: ['invalid', 'disposable'], or setEV_BLOCK_DISPOSABLE=true, to refuse throwaway addresses too;catch_allandunknownpass unless you add them.Strict or forgiving
By default an address passes when the check cannot finish, and a warning goes to your log. Set
EV_FAIL_OPEN=false, orfailOpen: falseon one rule, to fail the field with “We could not check the email right now” instead.
Set it up. 5 steps.
The short version of the full setup guide, which stays the reference when a step does not match what you see.
Download the package
The package is not on Packagist yet: download it from the guide and save it in a folder of your project, such as packages/.
Require it
Add that folder as a Composer repository with
composer config repositories.email-validation-laravel artifact ./packages, then runcomposer require email-validation/laravel:^0.1. Laravel discovers the service provider by itself.Set your key
Create an API key with Validate addresses and a daily credit cap, and put it in
.envasEV_API_KEY. The key is read from your configuration only; never put it in code.Add the rule
Add
new ValidEmail(), or the string rulevalid_email, after Laravel’s ownemailrule, withbailso a malformed address is never sent.Try it for free
Send the form with
accepted@sandbox.email-validation.org, which passes, andno_mailbox@sandbox.email-validation.org, which fails. Test addresses cost nothing.
Good to know.
- The rule gives the API 5 seconds for the check and waits 8 seconds for the answer, without retrying: a slow mail server then answers unknown, which passes and is free.
- Each result is kept in your cache for an hour under a SHA-256 hash of the address, so a form sent again after fixing another field is not checked or charged again. Only the status is kept, never the address, and unknown results are not kept.
- Publish the settings with
php artisan vendor:publish --tag=email-validation-config, and the messages with--tag=email-validation-langto change or translate them. The messages never show the API’s own error text. - A warning in your log carries the error code and the request id, never the address.
- For EU data residency, set
EV_BASE_URL=https://api-eu.email-validation.org: the same key works on both.
Updated · Maintained by the email-validation.org team