DEV Community

Cover image for Block fake and typo emails at signup in about 15 lines
Matthew Michels
Matthew Michels

Posted on

Block fake and typo emails at signup in about 15 lines

If you let any email into your database, you'll eventually pay for it. Typos, throwaway inboxes, dead domains. They bounce, they tank your sender reputation, and your real emails start landing in spam. Here's how I block them at signup.

The idea

Check the address before you save it. Keep the good ones, recover typos, drop the junk.

The code (Node)

const res = await fetch("https://YOUR-RAPIDAPI-HOST/", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-RapidAPI-Key": "YOUR_KEY",
"X-RapidAPI-Host": "YOUR-RAPIDAPI-HOST"
},
body: JSON.stringify({ email: req.body.email })
});
const r = await res.json();

if (r.status === "invalid" && r.did_you_mean) {
return reject(Did you mean ${r.did_you_mean}?); // recover the typo
}
if (r.status === "invalid" || r.checks.disposable) {
return reject("Please use a valid, non-disposable email.");
}
// r.status === "valid" -> save it

Enter fullscreen mode Exit fullscreen mode




What comes back

A verdict (valid / invalid / risky), a 0-100 score, and a per-check breakdown: syntax, MX (dead domain), disposable, role-based, free-webmail, plus a did_you_mean typo suggestion.

One honest caveat

It doesn't do SMTP mailbox probing. That gets you blocked and hurts your sending IP, so it's left out and the response says smtp_check: "skipped". It still catches typos, fakes, dead domains and role inboxes, which is the bulk of bad signups.

Free tier is 500/month if you want to try it: https://www.detroitwebagent.com/email-verification-api

Top comments (0)