Class: MailBounce::Recipient
- Inherits:
-
Object
- Object
- MailBounce::Recipient
- Defined in:
- lib/mailbounce/recipient.rb
Overview
One per-recipient block of a delivery status report (RFC 3464 §2.3).
Constant Summary collapse
- FAILED_ACTION =
"failed".freeze
- WRAPPED =
/\A["'<]|[">']\z/
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#diagnostic_code ⇒ Object
readonly
Returns the value of attribute diagnostic_code.
-
#final_recipient ⇒ Object
readonly
Returns the value of attribute final_recipient.
-
#original_recipient ⇒ Object
readonly
Returns the value of attribute original_recipient.
-
#remote_mta ⇒ Object
readonly
Returns the value of attribute remote_mta.
Instance Method Summary collapse
-
#address ⇒ Object
RFC 3464 §2.3.2 wants Final-Recipient; also try Original-Recipient and X-Failed-Recipients so an address-less block is not treated as anonymous (anonymous answers every name).
- #addressed_to?(recipient) ⇒ Boolean
- #anonymous? ⇒ Boolean
- #failed? ⇒ Boolean
-
#initialize(final_recipient: nil, original_recipient: nil, failed_recipient: nil, action: nil, status: nil, diagnostic_code: nil, remote_mta: nil) ⇒ Recipient
constructor
A new instance of Recipient.
- #permanent? ⇒ Boolean
- #permanent_failure? ⇒ Boolean
- #status ⇒ Object
Constructor Details
#initialize(final_recipient: nil, original_recipient: nil, failed_recipient: nil, action: nil, status: nil, diagnostic_code: nil, remote_mta: nil) ⇒ Recipient
Returns a new instance of Recipient.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/mailbounce/recipient.rb', line 10 def initialize(final_recipient: nil, original_recipient: nil, failed_recipient: nil, action: nil, status: nil, diagnostic_code: nil, remote_mta: nil) @final_recipient = final_recipient @original_recipient = original_recipient @failed_recipient = failed_recipient @action = action @status = status @diagnostic_code = diagnostic_code @remote_mta = remote_mta end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
8 9 10 |
# File 'lib/mailbounce/recipient.rb', line 8 def action @action end |
#diagnostic_code ⇒ Object (readonly)
Returns the value of attribute diagnostic_code.
8 9 10 |
# File 'lib/mailbounce/recipient.rb', line 8 def diagnostic_code @diagnostic_code end |
#final_recipient ⇒ Object (readonly)
Returns the value of attribute final_recipient.
8 9 10 |
# File 'lib/mailbounce/recipient.rb', line 8 def final_recipient @final_recipient end |
#original_recipient ⇒ Object (readonly)
Returns the value of attribute original_recipient.
8 9 10 |
# File 'lib/mailbounce/recipient.rb', line 8 def original_recipient @original_recipient end |
#remote_mta ⇒ Object (readonly)
Returns the value of attribute remote_mta.
8 9 10 |
# File 'lib/mailbounce/recipient.rb', line 8 def remote_mta @remote_mta end |
Instance Method Details
#address ⇒ Object
RFC 3464 §2.3.2 wants Final-Recipient; also try Original-Recipient and X-Failed-Recipients so an address-less block is not treated as anonymous (anonymous answers every name).
26 27 28 |
# File 'lib/mailbounce/recipient.rb', line 26 def address @address ||= sources.filter_map { |source| addressed(source) }.first.to_s end |
#addressed_to?(recipient) ⇒ Boolean
50 51 52 53 54 |
# File 'lib/mailbounce/recipient.rb', line 50 def addressed_to?(recipient) named = recipient.to_s.strip !named.empty? && named?(named) end |
#anonymous? ⇒ Boolean
30 31 32 |
# File 'lib/mailbounce/recipient.rb', line 30 def anonymous? address.empty? end |
#failed? ⇒ Boolean
34 35 36 |
# File 'lib/mailbounce/recipient.rb', line 34 def failed? action.to_s.strip.casecmp?(FAILED_ACTION) end |
#permanent? ⇒ Boolean
38 39 40 |
# File 'lib/mailbounce/recipient.rb', line 38 def permanent? status&.permanent? || false end |
#permanent_failure? ⇒ Boolean
42 43 44 |
# File 'lib/mailbounce/recipient.rb', line 42 def permanent_failure? failed? && permanent? end |