Class: Mail::Part

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

Constant Summary

Constant Summary

Constants included from Patterns

Mail::Patterns::ATOM_UNSAFE, Mail::Patterns::CONTROL_CHAR, Mail::Patterns::CRLF, Mail::Patterns::FIELD_BODY, Mail::Patterns::FIELD_LINE, Mail::Patterns::FIELD_NAME, Mail::Patterns::FIELD_PREFIX, Mail::Patterns::FIELD_SPLIT, Mail::Patterns::FWS, Mail::Patterns::HEADER_LINE, Mail::Patterns::HEADER_SPLIT, Mail::Patterns::PHRASE_UNSAFE, Mail::Patterns::QP_SAFE, Mail::Patterns::QP_UNSAFE, Mail::Patterns::TEXT, Mail::Patterns::TOKEN_UNSAFE, Mail::Patterns::WSP

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, #add_transfer_encoding, #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, #deliver, #deliver!, #delivery_method, #delivery_status_part, #delivery_status_report?, #destinations, #encode!, #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?, #has_transfer_encoding?, #header, #header=, #header_fields, #headers, #html_part, #html_part=, #in_reply_to, #in_reply_to=, #inform_interceptors, #inform_observers, #initialize, #inspect, #is_marked_for_delete?, #keywords, #keywords=, #main_type, #mark_for_delete=, #message_content_type, #message_id, #message_id=, #method_missing, #mime_parameters, #mime_type, #mime_version, #mime_version=, #multipart?, #multipart_report?, #part, #parts, #raw_envelope, #raw_source, #read, #ready_to_send!, #received, #received=, #references, #references=, #register_for_delivery_notification, #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, #transfer_encoding, #transport_encoding, #transport_encoding=, #without_attachments!

Methods included from Utilities

#atom_safe?, #bracket, #capitalize_field, #constantize, #dasherize, #dquote, #escape_paren, #map_lines, #map_with_index, #match_to_s, #paren, #quote_atom, #quote_phrase, #quote_token, #token_safe?, #unbracket, #underscoreize, #unparen, #unquote, #uri_escape, #uri_parser, #uri_unescape

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

- (Object) action

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



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

def action
  get_return_values('action')
end

- (Object) add_content_id(content_id_val = '')

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.



11
12
13
# File 'lib/mail/part.rb', line 11

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

- (Object) add_required_fields



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

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

- (Object) add_required_message_fields



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

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

- (Boolean) bounced?



57
58
59
60
61
62
63
# File 'lib/mail/part.rb', line 57

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

- (Object) cid



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

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

- (Object) delivery_status_data



53
54
55
# File 'lib/mail/part.rb', line 53

def delivery_status_data
  delivery_status_report_part? ? parse_delivery_status_report : {}
end

- (Boolean) delivery_status_report_part?



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

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

- (Object) diagnostic_code



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

def diagnostic_code
  get_return_values('diagnostic-code')
end

- (Object) error_status



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

def error_status
  get_return_values('status')
end

- (Object) final_recipient



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

def final_recipient
  get_return_values('final-recipient')
end

- (Boolean) has_content_id?

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.



17
18
19
# File 'lib/mail/part.rb', line 17

def has_content_id?
  header.has_content_id?
end

- (Boolean) inline?



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

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

- (Object) inline_content_id



21
22
23
24
25
# File 'lib/mail/part.rb', line 21

def inline_content_id
  # TODO: Deprecated in 2.2.2 - Remove in 2.3
  STDERR.puts("Part#inline_content_id is deprecated, please call Part#cid instead")
  cid
end

- (Object) remote_mta



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

def remote_mta
  get_return_values('remote-mta')
end

- (Boolean) retryable?



88
89
90
# File 'lib/mail/part.rb', line 88

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

- (Object) url



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

def url
  "cid:#{cid}"
end