Sha256: 3e737c2bbf7b0283820a0277ea1a3035f3206f99dd2ae510b1cc3f99ea8079ce
Contents?: true
Size: 1.07 KB
Versions: 13
Compression:
Stored size: 1.07 KB
Contents
require "email_assessor" require "resolv" require "mail" module EmailAssessor class Address attr_accessor :address def initialize(address) @parse_error = false @raw_address = address begin @address = Mail::Address.new(address) rescue Mail::Field::ParseError @parse_error = true end end def valid? return false if @parse_error if address.domain && address.address == @raw_address domain = address.domain # Valid address needs to have a dot in the domain !!domain.match(/\./) && !domain.match(/\.{2,}/) && domain.match(/[a-z]\Z/i) else false end end def disposable? valid? && EmailAssessor.domain_is_disposable?(address.domain) end def blacklisted? valid? && EmailAssessor.domain_is_blacklisted?(address.domain) end def valid_mx? return false unless valid? mx = [] Resolv::DNS.open do |dns| mx.concat dns.getresources(address.domain, Resolv::DNS::Resource::IN::MX) end mx.any? end end end
Version data entries
13 entries across 13 versions & 1 rubygems