Sha256: 79bdea7994e80681f88cdd847ffe2da96238ec31a4d8a47e13889a3e06d88a58
Contents?: true
Size: 1012 Bytes
Versions: 1
Compression:
Stored size: 1012 Bytes
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 # Valid address needs to have a dot in the domain !!address.domain.match(/\./) else false end end def disposable? valid? && ValidEmail2.disposable_emails.include?(address.domain) end def blacklisted? valid? && ValidEmail2.blacklist.include?(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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
valid_email2-1.1.5 | lib/valid_email2/address.rb |