Prerequisites
- Python 3.8+ with
ip-api-ioinstalled - A free ip-api.io API key
Fast check with email_info
A lightweight check (no SMTP probe): validates syntax, confirms the domain has MX records, and flags disposable/throwaway providers. Use it inline on sign-up forms.
import os
from ipapi_io import IpApiClient
client = IpApiClient(api_key=os.environ["IP_API_IO_KEY"])
info = client.email_info("user@example.com")
print(info["syntax"]["is_valid"]) # True
print(info["is_disposable"]) # False
print(info["has_mx_records"]) # True
print(info["mx_records"][0]["hostname"]) Full SMTP verification with validate_email
Advanced verification that connects to the mail server to confirm the mailbox is deliverable, and adds role-account, free-provider, catch-all and Gravatar signals.
result = client.validate_email("user@example.com")
print(result["reachable"]) # "yes" | "no" | "unknown"
print(result["smtp"]["deliverable"]) # True
print(result["smtp"]["catch_all"]) # False
print(result["disposable"]) # False
print(result["role_account"]) # False (e.g. info@, support@)
print(result["free"]) # False (e.g. gmail.com)
print(result.get("suggestion")) # typo fix, e.g. "user@gmail.com" Clean a list with validate_email_batch
Advanced-validate up to 100 addresses in one request — the building block for
email list cleaning. Raises
ValueError if the list is empty or longer than 100.
batch = client.validate_email_batch([
"user@example.com",
"fake@mailinator.com",
"info@example.org",
])
print(batch["totalProcessed"]) # 3
print(batch["successfulValidations"]) # 3
for email, result in batch["results"].items():
print(email, result["reachable"], result["disposable"])