Class: Mail::Part

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

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::FWS, Mail::Patterns::HEADER_LINE, Mail::Patterns::PHRASE_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=, #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, #filename, #find_first_mime_type, #from, #from=, #from_addrs, #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_observers, #initialize, #keywords, #keywords=, #main_type, #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_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, #sub_type, #subject, #subject=, #text_part, #text_part=, #to, #to=, #to_addrs, #to_s, #transfer_encoding

Methods included from Utilities

included

Methods included from Patterns

included

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



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

def action
  delivery_status_data['action'].value
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.



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

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

#add_required_fieldsObject



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

def add_required_fields
  add_content_id unless has_content_id?
  super
end

#bounced?Boolean

Returns:

  • (Boolean)


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

def bounced?
  !!(action =~ /failed/i)
end

#delivery_status_dataObject



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

def delivery_status_data
  delivery_status_report_part? ? parse_delivery_status_report : {}
end

#delivery_status_report_part?Boolean

Returns:

  • (Boolean)


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

def delivery_status_report_part?
  main_type =~ /message/i && sub_type =~ /delivery-status/i
end

#diagnostic_codeObject



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

def diagnostic_code
  delivery_status_data['diagnostic-code'].value
end

#error_statusObject



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

def error_status
  delivery_status_data['status'].value
end

#final_recipientObject



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

def final_recipient
  delivery_status_data['final-recipient'].value
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)


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

def has_content_id?
  header.has_content_id?
end

#remote_mtaObject



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

def remote_mta
  delivery_status_data['remote-mta'].value
end

#retryable?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/mail/part.rb', line 58

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