Skip to content

Instantly share code, notes, and snippets.

@chrisk
Created April 5, 2010 04:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisk/356034 to your computer and use it in GitHub Desktop.
Save chrisk/356034 to your computer and use it in GitHub Desktop.
Check an email address domain's validity using MX records
# Check an email address domain's validity using MX records
require 'resolv'
def known_email_domain?(email)
domain = email.match(/\@(.+)/)[1]
Resolv::DNS.open { |dns| dns.getresources(domain, Resolv::DNS::Resource::IN::MX) }.any?
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment