Prerequisites
- Node.js 18+ with
ip-api-ioinstalled - A free ip-api.io API key
Fast check with emailInfo
A lightweight check (no SMTP probe): validates syntax, confirms the domain has MX records, and flags disposable providers. Use it inline on sign-up forms.
import { IpApiClient } from "ip-api-io";
const client = new IpApiClient({ apiKey: process.env.IP_API_IO_KEY });
const info = await client.emailInfo("user@example.com");
console.log(info.syntax.is_valid); // true
console.log(info.is_disposable); // false
console.log(info.has_mx_records); // true
console.log(info.mx_records[0]?.hostname); Full SMTP verification with validateEmail
Connects to the mail server to confirm the mailbox is deliverable, and adds role-account, free-provider, catch-all, and Gravatar signals.
const result = await client.validateEmail("user@example.com");
console.log(result.reachable); // "yes" | "no" | "unknown"
console.log(result.smtp?.deliverable); // true
console.log(result.smtp?.catch_all); // false
console.log(result.disposable); // false
console.log(result.role_account); // false (e.g. info@, support@)
console.log(result.free); // false (e.g. gmail.com)
console.log(result.suggestion); // typo fix, e.g. "user@gmail.com" Clean a list with validateEmailBatch
Advanced-validate up to 100 addresses in one request — the building block for email list cleaning. Throws RangeError if the array is empty or longer than 100.
const batch = await client.validateEmailBatch([
"user@example.com",
"fake@mailinator.com",
"info@example.org",
]);
console.log(batch.totalProcessed); // 3
console.log(batch.successfulValidations); // 3
for (const [email, result] of Object.entries(batch.results)) {
console.log(email, result.reachable, result.disposable);
}