Skip to content

Instantly share code, notes, and snippets.

View godinc0's full-sized avatar
๐ŸŒ
https://godin.co

Marc-Andre G. godinc0

๐ŸŒ
https://godin.co
  • Montreal, Canada
View GitHub Profile
@afair
afair / get_mxers.rb
Created April 24, 2012 14:38
Ruby: lookup email MX servers for a domain
require 'resolv'
class Domain
def mxers(domain)
mxs = Resolv::DNS.open do |dns|
ress = dns.getresources(domain, Resolv::DNS::Resource::IN::MX)
ress.map { |r| [r.exchange.to_s, IPSocket::getaddress(r.exchange.to_s), r.preference] }
end
return mxs