Class: Truemail::Validate::Smtp

Inherits:
Base show all
Defined in:
lib/truemail/validate/smtp.rb,
lib/truemail/validate/smtp/request.rb,
lib/truemail/validate/smtp/response.rb

Defined Under Namespace

Classes: Request, Response

Constant Summary collapse

ERROR =
'smtp error'
RESPONSE_ATTRS =
%i[port_opened connection helo mailfrom rcptto errors].freeze

Instance Attribute Summary collapse

Attributes inherited from Worker

#result

Instance Method Summary collapse

Methods inherited from Worker

check

Constructor Details

#initialize(result) ⇒ Smtp

Returns a new instance of Smtp.


10
11
12
13
# File 'lib/truemail/validate/smtp.rb', line 10

def initialize(result)
  super(result)
  @smtp_results = []
end

Instance Attribute Details

#smtp_resultsObject (readonly)

Returns the value of attribute smtp_results


8
9
10
# File 'lib/truemail/validate/smtp.rb', line 8

def smtp_results
  @smtp_results
end

Instance Method Details

#runObject


15
16
17
18
19
20
21
22
23
# File 'lib/truemail/validate/smtp.rb', line 15

def run
  return false unless Truemail::Validate::Mx.check(result)
  establish_smtp_connection
  return true if success(success_response?)
  result.smtp_debug = smtp_results
  return true if success(not_includes_user_not_found_errors?)
  add_error(Truemail::Validate::Smtp::ERROR)
  false
end