Sha256: 9557251701dbc2c2d266c0be5b84ffe906240c24d389dfef1bb60dbc69af3f85
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
require "valid_email2" require "resolv" require "mail" module ValidEmail2 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,}/) else false end end def disposable? valid? && ValidEmail2.disposable_emails.select { |domain| address.domain =~ (/^(.*\.)*#{domain}$/i) }.any? end def blacklisted? valid? && ValidEmail2.blacklist.select { |domain| address.domain =~ (/^(.*\.)*#{domain}$/i) }.any? 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
valid_email2-1.2.0 | lib/valid_email2/address.rb |