Integrations · Forms
Validate emails on sign-up forms
Validating addresses at sign-up catches typos and throwaway inboxes before they reach your database, but a check must never stop a real person from signing up. The rule of thumb: block only what is clearly wrong, accept everything else, and re-check what was unclear later.
Call the API from your server
Validate in your sign-up handler on the server, not in browser code: your API key stays secret, and bots cannot spend your credits by calling the API directly. If you also want feedback while the person types, call your own endpoint, add a bot check (such as a CAPTCHA or Turnstile) and rate-limit it.
No server code at hand? The form guard checks the fields of any form in the browser with one script tag and a browser key limited to your site and a daily credit cap.
Validate once, when the form is submitted, rather than on every keystroke: each billable check costs a credit.
Keep it fast
Send "timeout": 6 (or anything from 5 to 15) so slow mail servers do not hold up the form. A check that runs out of time is unknown and free, and you can re-check it later.
Decide on the result
| Result | Suggested handling |
|---|---|
valid | Accept. |
invalid | Ask the person to fix the address. Offer did_you_mean when it is set. |
disposable, or the disposable field is true | Ask for a permanent address, if your product needs one. |
catch_all, or valid with the action send_with_caution (a role address, …) | Accept and flag (for example for a confirmation email or review). |
valid with the action remove (a spam trap, a frequent complainer, …) | Flag for review and send it nothing, not even a confirmation email, or ask for another address. |
unknown (without disposable: true) | Accept and re-check later. |
Error 402, 429 or 503, or no answer | Treat like unknown: accept and re-check later. |
JavaScript
// Returns { ok, message?, suggestion? } for your sign-up handler.
export async function screenSignupEmail(email, ip) {
let r;
try {
// With EU data residency, call our EU host instead (/docs/eu-data-residency/).
const res = await fetch('https://api.email-validation.org/v1/validate', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.EV_API_KEY}`,
'Content-Type': 'application/json',
},
// A short budget keeps the form fast; a check that runs out of time is unknown and free.
body: JSON.stringify({ email, ip_address: ip, timeout: 6 }),
signal: AbortSignal.timeout(10_000),
});
if (!res.ok) return { ok: true, recheck: true }; // 402, 429, 503 …: treat like unknown
r = await res.json();
} catch {
return { ok: true, recheck: true }; // network problem, timeout or an unreadable answer: accept, check later
}
if (r.status === 'invalid') {
return {
ok: false,
message: r.did_you_mean ? `Did you mean ${r.did_you_mean}?` : 'Please check this email address.',
suggestion: r.did_you_mean,
};
}
// disposable: true also comes with an unknown result for a known throwaway domain
if (r.status === 'disposable' || r.disposable === true) {
return { ok: false, message: 'Please use a permanent email address.' };
}
if (r.status === 'unknown') return { ok: true, recheck: true }; // no verdict yet (free): accept, check later
// valid, catch_all: accept; flag for review whenever the advice is not a plain send (a spam trap is valid with the
// action remove)
return { ok: true, flag: r.action !== 'send' };
}Python
import os
import requests # pip install requests
API = "https://api.email-validation.org/v1/validate" # with EU data residency, our EU host (/docs/eu-data-residency/)
def screen_signup_email(email: str, ip: str | None = None) -> dict:
"""Returns {"ok": bool, "message": str | None}. Never blocks on our errors."""
payload = {"email": email, "timeout": 6}
if ip:
payload["ip_address"] = ip
try:
resp = requests.post(
API,
headers={"Authorization": f"Bearer {os.environ['EV_API_KEY']}"},
json=payload,
timeout=10,
)
if not resp.ok: # 402, 429, 503 …: treat like unknown
return {"ok": True, "recheck": True}
r = resp.json()
except (requests.RequestException, ValueError): # network problem, timeout or an unreadable answer
return {"ok": True, "recheck": True}
if r["status"] == "invalid":
hint = f"Did you mean {r['did_you_mean']}?" if r["did_you_mean"] else "Please check this email address."
return {"ok": False, "message": hint}
# disposable True also comes with an unknown result for a known throwaway domain
if r["status"] == "disposable" or r["disposable"] is True:
return {"ok": False, "message": "Please use a permanent email address."}
if r["status"] == "unknown": # no verdict yet (free): accept, check later
return {"ok": True, "recheck": True}
return {"ok": True, "flag": r["action"] != "send"}Words that help
- Likely typo: "Did you mean name@gmail.com?" with a button that applies the suggestion.
- Invalid: "We could not deliver to this address. Please check it for typos."
- Disposable: "Please use an email address you will keep: we send your receipts and sign-in codes there."
Avoid messages that reveal how your screening works in detail, and never tell the person that "our provider" is down: just let them through.
Afterwards
- Re-check addresses flagged
unknownwith a bulk job or later single checks. - A confirmation email (double opt-in) or a trusted verified sign-in proves the person controls the mailbox; validation makes sure the message can arrive. A sign-in's verified flag can be historical: see what Google's email_verified tells you.
- Watch your bounce and complaint rates per sign-up source to tune what you accept.
Related
- Errors and retries
- The disposable status and the unknown status
- Test addresses to try every branch of your handler for free
- Form guard: the same rules in the browser, with one script tag