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/th
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-api.p.rapidapi.com/api/v1/validate?email=user%40gmial.com' \
--header 'x-rapidapi-key: YOUR_RAPIDAPI_KEY' \
--header 'x-rapidapi-host: email-validation-api.p.rapidapi.com'
The response includes valid, a reason (invalid_syntax / no_mx_records / disposable_email / valid), roleBased, freeProvider, and a suggestion for likely typos — [email protected] comes back with "suggestion": "[email protected]".
const res = await fetch(
`https://email-validation-api.p.rapidapi.com/api/v1/validate?email=${encodeURIComponent(email)}`,
{ headers: { 'x-rapidapi-key': process.env.RAPIDAPI_KEY, 'x-rapidapi-host': 'email-validation-api.p.rapidapi.com' } }
);
const { valid, reason, suggestion } = await res.json();
For bulk cleanup, POST { "emails": ["[email protected]", ...] } 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-api
Do you validate email at signup only, or re-check on every login attempt? Has a disposable address ever slipped through your current check?
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.