Class: Mail::Message
- Inherits:
-
Object
- Object
- Mail::Message
- Defined in:
- lib/kns_email_endpoint/core_extensions/message.rb
Instance Method Summary collapse
Instance Method Details
#delivered_to ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/kns_email_endpoint/core_extensions/message.rb', line 13 def delivered_to # Messages can be sent to multiple people AND if it was forwarded will have multiple # Delivered-To headers. What this bit of code does is take the # intersection of the "to" recipients and the "Delivered-To" recipients to find # out who the message was actually delivered to. There will almost never # be more than one recipient in that intersection, but if there is, we'll just # return the first. delivered_to_headers = [] self.header_fields.each { |f| delivered_to_headers << f.value if f.name == "Delivered-To"} actual_to = self.to.to_set.intersection delivered_to_headers return actual_to.first end |
#to_h ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/kns_email_endpoint/core_extensions/message.rb', line 3 def to_h { :to => to, :from => from, :subject => subject, :body => body.raw_source } end |