Prerequisites
- Ruby 3.0+ 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.
client = Ipapi::Client.new(api_key: ENV.fetch("IP_API_IO_KEY"))
info = client.email_info("user@example.com")
puts info.syntax.valid? # true
puts info.disposable? # false
puts info.mx_records? # true
puts info.mx_records.first.hostname unless info.mx_records.empty? 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")
puts result.reachable # "yes" | "no" | "unknown"
if result.smtp
puts "#{result.smtp.deliverable?} #{result.smtp.catch_all?}"
end
puts result.disposable? # false
puts result.role_account? # false (e.g. info@, support@)
puts result.free? # false (e.g. gmail.com)
puts result.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
ArgumentError if the array is empty or longer than 100.
batch = client.validate_email_batch([
"user@example.com",
"fake@mailinator.com"
])
puts batch.total_processed # 2
puts batch.successful_validations # 2
batch.results.each do |email, result|
puts "#{email} #{result.reachable} #{result.disposable?}"
end