Class: Mail::Part

Inherits:
Message show all
Defined in:
lib/mail/part.rb

Instance Attribute Summary

Attributes inherited from Message

#delivery_handler, #perform_deliveries, #raise_delivery_errors

Instance Method Summary collapse

Methods inherited from Message

#<=>, #==, #[], #[]=, #add_charset, #add_content_transfer_encoding, #add_content_type, #add_date, #add_file, #add_message_id, #add_mime_version, #add_part, #all_parts, #attachment, #attachment?, #attachments, #bcc, #bcc=, #bcc_addrs, #body, #body=, #body_encoding, #body_encoding=, #boundary, #cc, #cc=, #cc_addrs, #charset, #charset=, #comments, #comments=, #content_description, #content_description=, #content_disposition, #content_disposition=, #content_id, #content_id=, #content_location, #content_location=, #content_transfer_encoding, #content_transfer_encoding=, #content_type, #content_type=, #content_type_parameters, #convert_to_multipart, #date, #date=, #decode_body, #decoded, #default, default_charset, default_charset=, #deliver, #deliver!, #delivery_method, #delivery_status_part, #delivery_status_report?, #destinations, #encoded, #envelope_date, #envelope_from, #errors, #filename, #find_first_mime_type, #from, #from=, #from_addrs, from_hash, from_yaml, #has_attachments?, #has_charset?, #has_content_transfer_encoding?, #has_content_type?, #has_date?, #has_message_id?, #has_mime_version?, #header, #header=, #header_fields, #headers, #html_part, #html_part=, #in_reply_to, #in_reply_to=, #inform_interceptors, #inform_observers, #initialize, #initialize_copy, #inspect, #inspect_structure, #is_marked_for_delete?, #keywords, #keywords=, #main_type, #mark_for_delete=, #message_id, #message_id=, #method_missing, #mime_type, #mime_version, #mime_version=, #multipart?, #multipart_report?, #part, #parts, #raw_envelope, #raw_source, #read, #ready_to_send!, #received, #received=, #references, #references=, #reply, #reply_to, #reply_to=, #resent_bcc, #resent_bcc=, #resent_cc, #resent_cc=, #resent_date, #resent_date=, #resent_from, #resent_from=, #resent_message_id, #resent_message_id=, #resent_sender, #resent_sender=, #resent_to, #resent_to=, #return_path, #return_path=, #sender, #sender=, #set_envelope, #skip_deletion, #smtp_envelope_from, #smtp_envelope_from=, #smtp_envelope_to, #smtp_envelope_to=, #sub_type, #subject, #subject=, #text?, #text_part, #text_part=, #to, #to=, #to_addrs, #to_s, #to_yaml, #transport_encoding, #transport_encoding=, #without_attachments!

Constructor Details

This class inherits a constructor from Mail::Message

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Mail::Message

Instance Method Details

#actionObject

Either returns the action if the message has just a single report, or an array of all the actions, one for each report



65
66
67
# File 'lib/mail/part.rb', line 65

def action
  get_return_values('action')
end

#add_content_id(content_id_val = '') ⇒ Object

Creates a new empty Content-ID field and inserts it in the correct order into the Header. The ContentIdField object will automatically generate a unique content ID if you try and encode it or output it to_s without specifying a content id.

It will preserve the content ID you specify if you do.



14
15
16
# File 'lib/mail/part.rb', line 14

def add_content_id(content_id_val = '')
  header['content-id'] = content_id_val
end

#add_required_fieldsObject



37
38
39
40
# File 'lib/mail/part.rb', line 37

def add_required_fields
  super
  add_content_id if !has_content_id? && inline?
end

#add_required_message_fieldsObject



42
43
44
# File 'lib/mail/part.rb', line 42

def add_required_message_fields
  # Override so we don't add Date, MIME-Version, or Message-ID.
end

#bounced?Boolean

Returns:

  • (Boolean)


54
55
56
57
58
59
60
# File 'lib/mail/part.rb', line 54

def bounced?
  if action.is_a?(Array)
    !!(action.first =~ /failed/i)
  else
    !!(action =~ /failed/i)
  end
end

#cidObject



24
25
26
27
# File 'lib/mail/part.rb', line 24

def cid
  add_content_id unless has_content_id?
  Utilities.uri_escape(Utilities.unbracket(content_id))
end

#delivery_status_dataObject



50
51
52
# File 'lib/mail/part.rb', line 50

def delivery_status_data
  delivery_status_report_part? ? parse_delivery_status_report : {}
end

#delivery_status_report_part?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/mail/part.rb', line 46

def delivery_status_report_part?
  (main_type =~ /message/i && sub_type =~ /delivery-status/i) && body =~ /Status:/
end

#diagnostic_codeObject



77
78
79
# File 'lib/mail/part.rb', line 77

def diagnostic_code
  get_return_values('diagnostic-code')
end

#error_statusObject



73
74
75
# File 'lib/mail/part.rb', line 73

def error_status
  get_return_values('status')
end

#final_recipientObject



69
70
71
# File 'lib/mail/part.rb', line 69

def final_recipient
  get_return_values('final-recipient')
end

#has_content_id?Boolean

Returns true if the part has a content ID field, the field may or may not have a value, but the field exists or not.

Returns:

  • (Boolean)


20
21
22
# File 'lib/mail/part.rb', line 20

def has_content_id?
  header.has_content_id?
end

#inline?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/mail/part.rb', line 33

def inline?
  header[:content_disposition].disposition_type == 'inline' if header[:content_disposition].respond_to?(:disposition_type)
end

#remote_mtaObject



81
82
83
# File 'lib/mail/part.rb', line 81

def remote_mta
  get_return_values('remote-mta')
end

#retryable?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/mail/part.rb', line 85

def retryable?
  !(error_status =~ /^5/)
end

#urlObject



29
30
31
# File 'lib/mail/part.rb', line 29

def url
  "cid:#{cid}"
end