lib/cogi_email/checker.rb
##
# Returns server object for given email address or throws exception
# Object returned isn't yet connected. It has internally a list of
# real mail servers got from MX dns lookup
#
# Reference:
#   https://github.com/kamilc/email_verifier/blob/master/lib/email_verifier/checker.rb
Returns server object for given email address or throws exception
Object returned isn't yet connected. It has internally a list of
real mail servers got from MX dns lookup


Returns server object for given email address or throws exception Object returned isn ' t yet connected . It has internally a list of real mail servers got from MX dns lookup
def list_mxs
      return [] unless domain
      mxs = []
      Resolv::DNS.open do |dns|
        ress = dns.getresources domain, Resolv::DNS::Resource::IN::MX
        ress.each do |r|
          mxs << { priority: r.preference, address: r.exchange.to_s }
        end
      end
      @servers = mxs.sort_by { |mx| mx[:priority] }
      @servers
    end
def list_mxs return [ ] unless domain mxs = [ ] Resolv :: DNS . open do | dns | ress = dns . getresources domain , Resolv :: DNS :: Resource :: IN :: MX ress . each do | r | mxs << { priority : r . preference , address : r . exchange . to_s } end end @servers = mxs . sort_by { | mx | mx [ :priority ] } @servers end
Returns server object for given email address or throws exception
Object returned isn't yet connected.
Returns server object for given email address or throws exception Object returned isn ' t yet connected .