Class: AlchemyCrm::BouncedDelivery
- Inherits:
-
Object
- Object
- AlchemyCrm::BouncedDelivery
- Defined in:
- lib/alchemy_crm/bounced_delivery.rb
Instance Attribute Summary collapse
-
#attr_names ⇒ Object
Returns the value of attribute attr_names.
-
#message ⇒ Object
Returns the value of attribute message.
-
#original_message_id ⇒ Object
Returns the value of attribute original_message_id.
-
#status_info ⇒ Object
Returns the value of attribute status_info.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#attr_names ⇒ Object
Returns the value of attribute attr_names.
5 6 7 |
# File 'lib/alchemy_crm/bounced_delivery.rb', line 5 def attr_names @attr_names end |
#message ⇒ Object
Returns the value of attribute message.
6 7 8 |
# File 'lib/alchemy_crm/bounced_delivery.rb', line 6 def @message end |
#original_message_id ⇒ Object
Returns the value of attribute original_message_id.
4 5 6 |
# File 'lib/alchemy_crm/bounced_delivery.rb', line 4 def @original_message_id end |
#status_info ⇒ Object
Returns the value of attribute status_info.
4 5 6 |
# File 'lib/alchemy_crm/bounced_delivery.rb', line 4 def status_info @status_info end |
Class Method Details
.from_email(email) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/alchemy_crm/bounced_delivery.rb', line 8 def self.from_email(email) returning(bounce = self.new) do plain_part = email.parts.detect do |part| part.content_type == 'text/plain' end bounce. = plain_part.body.strip status_part = email.parts.detect do |part| part.content_type == "message/delivery-status" end statuses = status_part.body.split(/\n/) bounce.status_info = statuses.inject({}) do |hash, line| key, value = line.split(/:/) hash[key] = value.strip rescue nil hash end = email.parts.detect do |part| part.content_type == "message/rfc822" or part.content_type == "text/rfc822-headers" end parsed_msg = Mail.parse(.body) bounce. = parsed_msg. end end |
Instance Method Details
#status ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/alchemy_crm/bounced_delivery.rb', line 34 def status case status_info['Status'] when /^5/ 'Failure' when /^4/ 'Temporary Failure' when /^2/ 'Success' end end |