Integrations · Frameworks and SDKs

Validate emails in apps on Ploi

Ploi deploys your app; the check runs in your app's code. For a Laravel app that is our Laravel validation rule, which rejects an address that cannot receive email in any form request. Ploi's part is the key: it goes in the site's .env file through Ploi's environment editor, never in your repository. Ploi 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 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. Ploi's deploy script then installs it with the rest of your dependencies. Add the rule to your form requests:

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

The key in Ploi

  1. Create an API key on the API keys page with the permission "Validate addresses", one for each site, with a daily credit cap. Put the form's route behind Laravel's throttle middleware: each address a visitor sends can use a credit.

  2. In Ploi, open the site and edit its environment (the site's .env file), and add:

    EV_API_KEY=your-api-key
  3. If your app caches its configuration (php artisan config:cache, usual in a production deploy script), run it again, or deploy again, so the app reads the new value. Restart queue workers if you validate in queued jobs.

Optional settings go in the same file: 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 (the same key works on both). The 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 cost nothing and contact no mail server.

Not a Laravel app

Ploi also runs other PHP apps and Node.js apps. The environment editor 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, such as the PHP or the 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.

Ploi's own documentation: its documentation and the .env endpoints of its API.

More on Ploi

Updated · Maintained by: Email Validation LLC

Need help? Contact support, or ask the help chat. Something wrong or missing on this page? Tell us