# Laravel Forge Setup: Email Validation with an Env Key

URL: https://email-validation.org/docs/guides/laravel-forge/
Updated: 2026-12-04

> Documentation index: https://email-validation.org/llms.txt

Laravel Forge deploys your app; the check runs in your app's code. For a Laravel app that is our
[Laravel validation rule](https://email-validation.org/docs/guides/laravel/), which rejects an address that cannot receive email in any form
request. Forge's part is the key: it goes in the site's environment, from Forge's **Environment** panel, never in your
repository. Forge adds nothing of its own and needs no plugin.

By default the rule never stops a real person when the API cannot answer in time: the address passes and a warning
goes to your log (`EV_FAIL_OPEN`, below).

## Add the rule to your app

Install the package in your app as the [Laravel guide](https://email-validation.org/docs/guides/laravel/#install) says: it is not on Packagist
yet, so commit the downloaded zip in a folder of your repository (for example `packages/`) with the Composer
repository line, and commit `composer.json` and `composer.lock`. Forge's deployment then installs it with the rest
of your dependencies. Add the rule to your form requests:

```php
'email' => ['bail', 'required', 'email', new ValidEmail()],
```

## The key in Forge

1. Create an API key on the [API keys page](https://email-validation.org/app/api-keys/) with the permission "Validate addresses", one for each
   site, with a [daily credit cap](https://email-validation.org/docs/authentication/#limits). Put the form's route behind Laravel's `throttle`
   middleware: each address a visitor sends can use a credit.
2. In Forge, open the site, then **Settings → Environment**, and add:

   ```bash
   EV_API_KEY=your-api-key
   ```

   Forge writes it to the site's `.env` file (shared by every release with zero-downtime deployments).
3. Save with Forge's option to run `php artisan config:cache` (on Laravel and Statamic sites), so a cached
   configuration reads the new value; tick `php artisan queue:restart` too if you validate in queued jobs.

Optional settings go in the same panel: `EV_BLOCK_DISPOSABLE=true` to reject throwaway inboxes too,
`EV_FAIL_OPEN=false` to fail the field when the check cannot finish, and `EV_BASE_URL=https://api-eu.email-validation.org` for
[EU data residency](https://email-validation.org/docs/eu-data-residency/) (the same key works on both). The [settings](https://email-validation.org/docs/guides/laravel/#settings)
list every one.

## Try it

Send the form with `no_mailbox@sandbox.email-validation.org`: the field fails. `accepted@sandbox.email-validation.org` passes. These
[test addresses](https://email-validation.org/docs/test-addresses/) cost nothing and contact no mail server.

## Not a Laravel app

Forge also deploys other PHP apps and Node.js apps. The Environment panel writes the same `.env` file, which your
app loads itself (in Node.js, for example, with `node --env-file=.env`). Read `EV_API_KEY` from the environment with
one of our [SDKs](https://email-validation.org/docs/sdks/), such as the [PHP](https://email-validation.org/docs/sdks/php/) or the [JavaScript](https://email-validation.org/docs/sdks/javascript/) one,
and let the form through when the check fails, so an outage on our side never stops a visitor. There are official SDKs for JavaScript/TypeScript, Python, Go, PHP, Ruby, C#, Rust and Swift; those for Java, Kotlin, Dart, Elixir, C and Perl are built and tested and coming soon to their package registries.

Forge's own documentation: [Environment variables](https://forge.laravel.com/docs/sites/environment-variables).

## Related

- [Laravel](https://email-validation.org/docs/guides/laravel/)
- [Ploi](https://email-validation.org/docs/guides/ploi/)
- [Authentication and key limits](https://email-validation.org/docs/authentication/)

## More on Laravel Forge

- [Laravel Forge email validation integration](https://email-validation.org/integrations/laravel-forge/)
