DEV Community

Daniel Igel
Daniel Igel

Posted on

Syntax + MX + disposable detection: complete email validation in one call

Validating email addresses properly requires at least three independent checks: RFC 5322 syntax, a live MX record lookup (a correctly formatted address can point to a domain with no active mail server), and disposable/throwaway domain detection. Wiring all three yourself means shipping a DNS resolver, maintaining a blocklist, and gluing the pieces together — per runtime.

One GET runs all checks in a single call:

curl --request GET \
  --url 'https://email-validation-api37.p.rapidapi.com/api/v1/validate?email=user%40gmial.com' \
  --header 'x-rapidapi-key: YOUR_RAPIDAPI_KEY' \
  --header 'x-rapidapi-host: email-validation-api37.p.rapidapi.com'
Enter fullscreen mode Exit fullscreen mode

The response includes valid, a reason (invalid_syntax / no_mx_records / disposable_email / valid), roleBased, freeProvider, and a suggestion for likely typos — user@gmial.com comes back with "suggestion": "user@gmail.com".

const res = await fetch(
  `https://email-validation-api37.p.rapidapi.com/api/v1/validate?email=${encodeURIComponent(email)}`,
  { headers: { 'x-rapidapi-key': process.env.RAPIDAPI_KEY, 'x-rapidapi-host': 'email-validation-api37.p.rapidapi.com' } }
);
const { valid, reason, suggestion } = await res.json();
Enter fullscreen mode Exit fullscreen mode

For bulk cleanup, POST { "emails": ["a@b.com", ...] } to the same path — returns per-email results and a summary (total / valid / invalid). Handles up to 100 addresses per request.

Free tier on RapidAPI: https://rapidapi.com/danieligel/api/email-validation-api37

Do you validate email at signup only, or re-check on every login attempt? Has a disposable address ever slipped through your current check?

Top comments (0)