Rails 根据email地址获取对应的邮件服务器信息

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

require 'resolv'

dns = Resolv::DNS.new
domain = "oreilly.com"
dns.each_resource(domain, Resolv::DNS::Resource::IN::MX) do |mail_server|
  puts mail_server.exchange
end
# smtp1.oreilly.com
# smtp2.oreilly.com
==
Get name server

require 'resolv'

dns = Resolv::DNS.new

dns.each_resource(domain, Resolv::DNS::Resource::IN::NS) do |nameserver|
  puts nameserver.name
end
# a.auth-ns.sonic.net
# b.auth-ns.sonic.net
# c.auth-ns.sonic.net
# ns.oreilly.com