DEV Community

Alexey D
Alexey D

Posted on

How to Validate Email Addresses in JavaScript — Deliverability Score API

How to Validate Email Addresses in JavaScript — Deliverability Score API

Regex will not save you. You can validate email format perfectly and still end up with a list full of disposable addresses, catch-all domains, and role-based inboxes that kill your sender reputation.

This guide shows how to do real email validation in JavaScript and Python using a free API that checks MX records, disposable domains, and returns a quality score (0–100).

The API: Email Validator Pro

👉 Email Validator Pro on RapidAPI

  • MX record lookup (does the domain actually receive mail?)
  • 300+ disposable domain blocklist (mailinator, guerrilla, etc.)
  • Role-based address detection (admin@, info@, noreply@)
  • Catch-all domain detection
  • Quality score 0–100
  • Batch endpoint (up to 50 emails)

Sample Response

{
  "email": "test@gmail.com",
  "is_valid": true,
  "mx_valid": true,
  "is_disposable": false,
  "is_role_based": false,
  "quality_score": 95,
  "domain": "gmail.com"
}
Enter fullscreen mode Exit fullscreen mode

JavaScript Example

async function validateEmail(email) {
  const res = await fetch("https://emailvalidatorpro.p.rapidapi.com/validate", {
    method: "POST",
    headers: {
      "X-RapidAPI-Key": "YOUR_KEY",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({ email })
  });

  const data = await res.json();

  if (!data.is_valid || data.is_disposable) {
    console.log("Rejected:", email);
    return false;
  }

  console.log(`Score: ${data.quality_score}/100 | MX: ${data.mx_valid}`);
  return true;
}

// Examples
validateEmail("user@gmail.com");      // Score: 95/100 | MX: true
validateEmail("fake@mailinator.com"); // Rejected: fake@mailinator.com
validateEmail("info@company.com");    // Role-based — handle accordingly
Enter fullscreen mode Exit fullscreen mode

Python Example

import requests

def validate_email(email):
    url = "https://emailvalidatorpro.p.rapidapi.com/validate"
    headers = {
        "X-RapidAPI-Key": "YOUR_KEY",
        "Content-Type": "application/json"
    }
    r = requests.post(url, json={"email": email}, headers=headers)
    data = r.json()

    return {
        "valid": data["is_valid"],
        "mx": data["mx_valid"],
        "disposable": data["is_disposable"],
        "role_based": data["is_role_based"],
        "score": data["quality_score"]
    }

# Usage
print(validate_email("test@gmail.com"))
# {"valid": True, "mx": True, "disposable": False, "role_based": False, "score": 95}

print(validate_email("user@mailinator.com"))
# {"valid": True, "mx": True, "disposable": True, "role_based": False, "score": 5}
Enter fullscreen mode Exit fullscreen mode

Batch Validation

import requests

emails = [
    "user@gmail.com",
    "fake@mailinator.com",
    "info@company.com",
    "bad@nonexistent-domain-xyz.com"
]

r = requests.post(
    "https://emailvalidatorpro.p.rapidapi.com/batch",
    json={"emails": emails},
    headers={"X-RapidAPI-Key": "YOUR_KEY", "Content-Type": "application/json"}
)

for item in r.json():
    status = "" if item["is_valid"] and not item["is_disposable"] else ""
    print(f"{status} {item['email']:<30} score:{item['quality_score']}")
Enter fullscreen mode Exit fullscreen mode

When to Block vs Warn

Condition Action
is_valid: false Block always
mx_valid: false Block — email can't be delivered
is_disposable: true Block on sign-up
is_role_based: true Warn user or flag for review
quality_score < 40 Ask user to double-check

Free Tier

Free tier available — no credit card needed.

👉 Subscribe here: Email Validator Pro on RapidAPI


Also check out: Phone Validator Pro | Language Detector Pro

Top comments (0)