Created
April 5, 2010 04:49
-
-
Save chrisk/356034 to your computer and use it in GitHub Desktop.
Check an email address domain's validity using MX records
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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