E-mail check at sign-up

Catch typos and missing mailboxes at sign-up with the MobileValidate e-mail check: fix invalid addresses, confirm unknown mailboxes and allow uncertain answers. Node and Python.

Last updated

View as Markdown

This recipe checks an e-mail address before you send the confirmation e-mail. It catches typos and mailboxes that don't exist, without blocking real users on uncertain answers. There is a Node version and a Python version.

What does it decide?

ResultDecision
email_status is not validFix: show the API's suggestion, such as a mistyped domain
registered: falseConfirm: "We couldn't find this mailbox. Is the address spelled correctly?"
registered: trueAllow
registered: null (unknown)Allow
The check failsAllow, and log the error code and request id

What does the code look like?

JavaScript
const { data, error } = await mv.lookup({ emails: [email], checks: ["email"], wait: 5, waitTimeoutMs: 8_000 });
if (error) return { decision: "allow" };                    // fail open
const row = data.results[0];
if (row.email_status !== "valid") return { decision: "fix", message: row.suggestion };
const registered = row.checks["email.valid"].registered;
if (registered === false) return { decision: "confirm" };
return { decision: "allow" };                               // true, or null (unknown)
Python
lookup = mv.lookup(emails=[email], checks=["email"], wait=5, wait_timeout=8)
row = lookup["results"][0]
registered = row.get("checks", {}).get("email.valid", {}).get("registered")  # True / False / None

How do I test it?

Use the test addresses on test.mobilevalidate.com with the public sandbox key: registered@ allows, not-registered@ asks to confirm, unknown@ allows and pending@ allows after about 5 seconds. See test values. Log the error code and requestId, never the address itself.

Frequently asked questions

Should I block sign-ups when the mailbox is not found?

No. Ask the user to confirm the spelling and let them continue if they insist. Block only addresses that are invalid.

Does the e-mail check return names or profiles?

No. E-mail answers are yes, no or unknown only.