Sha256: 750cfbc15c47e12887e1d489eeab682e93a2613f35e5eb5e6dced193e4e33680
Contents?: true
Size: 970 Bytes
Versions: 1
Compression:
Stored size: 970 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 tree = address.send(:tree) # Valid address needs to have a dot in the domain tree.domain.dot_atom_text.elements.size > 1 else false end end def disposable? valid? && ValidEmail2.disposable_emails.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.0.0 | lib/valid_email2/address.rb |