Integrations · Frameworks and SDKs

Validate emails in apps on Coolify

Coolify deploys your app; the check runs in your app's code, with one of our SDKs or framework integrations such as Laravel, Django or Rails. Coolify's part is the key: an environment variable on the app's Environment Variables page, locked so its value is hidden, and given to the running container only, never to the build. Coolify adds nothing of its own and needs no plugin.

The key in Coolify

  1. Create an API key on the API keys page with the permission "Validate addresses", one for each app, with a daily credit cap. Limit how often a visitor can send the form: each address sent can use a credit.
  2. In Coolify, open the app, then Environment Variables, and add EV_API_KEY with the key as its value. Make it available at runtime only, not during the build: the app reads it once it runs, and a build argument can stay visible in the image's metadata.
  3. Lock it, so Coolify hides the value in its UI and API. A locked value cannot be shown again; to change it, enter a new value and update the variable.
  4. Restart the app, so the running container gets the variable (a change that only affects runtime needs no new build).

For EU data residency, add EV_BASE_URL with the value https://api-eu.email-validation.org the same way; the same key works on both.

A Docker Compose app

Coolify shows each ${…} a Compose file names as one of the app's variables, and does not deploy while a variable written as ${NAME:?} is empty. So name the key in your Compose file and leave its value to Coolify:

# A Docker Compose example for an app Coolify deploys from a Compose file (docs: /docs/guides/coolify/).
# The key is never written here: Coolify shows EV_API_KEY on the app's Environment Variables page, where you set it
# (locked, runtime only). `:?` makes it required: Coolify does not deploy while it is empty.
services:
  app:
    build: .
    environment:
      EV_API_KEY: ${EV_API_KEY:?}
      # For EU data residency, set EV_BASE_URL to the EU host on the same page; empty means the default host.
      EV_BASE_URL: ${EV_BASE_URL:-}

The check in your app

In a Node.js app, add the JavaScript SDK (npm install @email-validation/sdk) and copy this check into your code. It stops only the statuses you list and lets the form through when the check fails (no key, no credits left, a timeout, the API out of reach), so an outage on our side never stops a visitor:

export interface Checker {
  validate(email: string): Promise<{ status: string; reason?: string }>;
}

export interface CheckResult {
  /** false only when the result's status is one of `stop`. */
  ok: boolean;
  /** The result's status, or `unchecked` when the check failed. */
  status: string;
}

export const DEFAULT_STOP: readonly string[] = ['invalid', 'disposable'];

export async function checkEmail(
  client: Checker | (() => Checker),
  email: string,
  stop: readonly string[] = DEFAULT_STOP,
): Promise<CheckResult> {
  try {
    const result = await (typeof client === 'function' ? client() : client).validate(email);
    return { ok: !stop.includes(result.status), status: result.status };
  } catch {
    return { ok: true, status: 'unchecked' };
  }
}

Make the client on the first check, from the variables Coolify sets, and check the form's address before you accept it. Made inside the check, a missing key is one more error that lets the form through, never an app that fails to start or, with a runtime-only variable, to build:

import { EmailValidation } from '@email-validation/sdk';

let ev: EmailValidation | undefined;
const client = () =>
  (ev ??= new EmailValidation({
    apiKey: process.env.EV_API_KEY ?? '',
    baseUrl: process.env.EV_BASE_URL || undefined,
  }));

const { ok } = await checkEmail(client, form.email);
if (!ok) {
  // show "Please check your email address" and keep the form open
}

In another language, read EV_API_KEY from the environment with that language's SDK the same way. 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.

Try it

Send the form with no_mailbox@sandbox.email-validation.org: it is stopped. accepted@sandbox.email-validation.org goes through. These test addresses cost nothing and contact no mail server. Each real check costs at most 1 credit; unknown results, errors and test addresses are free.

Coolify's own documentation: Environment variables.

More on Coolify

Updated · Maintained by: Email Validation LLC

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