Class: EmailDetected::Checker::MailCheckStatus
- Inherits:
-
Object
- Object
- EmailDetected::Checker::MailCheckStatus
- Defined in:
- lib/email_detected/checker.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(response_code, error = nil) ⇒ MailCheckStatus
constructor
A new instance of MailCheckStatus.
-
#invalid? ⇒ Boolean
true if verified address is known to be invalid.
-
#status ⇒ Object
Symbolic status of mail address verification.
-
#valid? ⇒ Boolean
true if verified address is known to be valid.
Constructor Details
#initialize(response_code, error = nil) ⇒ MailCheckStatus
Returns a new instance of MailCheckStatus.
30 31 32 33 34 35 36 37 38 |
# File 'lib/email_detected/checker.rb', line 30 def initialize(response_code, error = nil) errors = Array.new unless error.nil? errors.push(EmailDetected::MESSAGES[response_code]) end @response = (self.class.rcpt_responses.has_key?(response_code) ? response_code : -1) @errors = errors end |
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
7 8 9 |
# File 'lib/email_detected/checker.rb', line 7 def errors @errors end |
Class Method Details
.rcpt_responses ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/email_detected/checker.rb', line 9 def self.rcpt_responses @@rcpt_responses ||= { -1 => :fail, # Validation failed (non-SMTP) 250 => :valid, # Requested mail action okay, completed 251 => :dunno, # User not local; will forward to <forward-path> 550 => :invalid, # Requested action not taken:, mailbox unavailable 551 => :dunno, # User not local; please try <forward-path> 552 => :valid, # Requested mail action aborted:, exceeded storage allocation 553 => :invalid, # Requested action not taken:, mailbox name not allowed 450 => :valid_fails, # Requested mail action not taken:, mailbox unavailable 451 => :valid_fails, # Requested action aborted:, local error in processing 452 => :valid_fails, # Requested action not taken:, insufficient system storage 500 => :fail, # Syntax error, command unrecognised 501 => :invalid, # Syntax error in parameters or arguments 503 => :fail, # Bad sequence of commands 521 => :invalid, # <domain> does not accept mail [rfc1846] 421 => :fail, # <domain> Service not available, closing transmission channel } end |
Instance Method Details
#invalid? ⇒ Boolean
true if verified address is known to be invalid
57 58 59 |
# File 'lib/email_detected/checker.rb', line 57 def invalid? self.status == :invalid end |
#status ⇒ Object
Symbolic status of mail address verification.
- :fail
-
Verification failed
- :dunno
-
Verification succeeded, but can’t tell about validity
- :valid
-
address known to be valid
- :valid_fails
-
address known to be valid, delivery would have failed temporarily
- :invalid
-
address known to be invalid
47 48 49 |
# File 'lib/email_detected/checker.rb', line 47 def status @@rcpt_responses[@response] end |
#valid? ⇒ Boolean
true if verified address is known to be valid
52 53 54 |
# File 'lib/email_detected/checker.rb', line 52 def valid? [:valid, :valid_fails].include? self.status end |