rack-mail_exception 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +22 -0
- data/LICENSE +20 -0
- data/README.rdoc +38 -0
- data/Rakefile +56 -0
- data/VERSION +1 -0
- data/lib/rack/mail_exception.rb +103 -0
- data/test/helper.rb +13 -0
- data/test/test_rack_mail_exception.rb +93 -0
- data/vendor/mail/.bundle/config +2 -0
- data/vendor/mail/CHANGELOG.rdoc +370 -0
- data/vendor/mail/Dependencies.txt +3 -0
- data/vendor/mail/Gemfile +17 -0
- data/vendor/mail/README.rdoc +572 -0
- data/vendor/mail/ROADMAP +92 -0
- data/vendor/mail/Rakefile +41 -0
- data/vendor/mail/TODO.rdoc +9 -0
- data/vendor/mail/lib/mail.rb +76 -0
- data/vendor/mail/lib/mail/attachments_list.rb +99 -0
- data/vendor/mail/lib/mail/body.rb +287 -0
- data/vendor/mail/lib/mail/configuration.rb +67 -0
- data/vendor/mail/lib/mail/core_extensions/blank.rb +26 -0
- data/vendor/mail/lib/mail/core_extensions/nil.rb +11 -0
- data/vendor/mail/lib/mail/core_extensions/string.rb +27 -0
- data/vendor/mail/lib/mail/elements.rb +14 -0
- data/vendor/mail/lib/mail/elements/address.rb +306 -0
- data/vendor/mail/lib/mail/elements/address_list.rb +74 -0
- data/vendor/mail/lib/mail/elements/content_disposition_element.rb +30 -0
- data/vendor/mail/lib/mail/elements/content_location_element.rb +25 -0
- data/vendor/mail/lib/mail/elements/content_transfer_encoding_element.rb +24 -0
- data/vendor/mail/lib/mail/elements/content_type_element.rb +35 -0
- data/vendor/mail/lib/mail/elements/date_time_element.rb +26 -0
- data/vendor/mail/lib/mail/elements/envelope_from_element.rb +34 -0
- data/vendor/mail/lib/mail/elements/message_ids_element.rb +29 -0
- data/vendor/mail/lib/mail/elements/mime_version_element.rb +26 -0
- data/vendor/mail/lib/mail/elements/phrase_list.rb +21 -0
- data/vendor/mail/lib/mail/elements/received_element.rb +30 -0
- data/vendor/mail/lib/mail/encodings.rb +258 -0
- data/vendor/mail/lib/mail/encodings/7bit.rb +31 -0
- data/vendor/mail/lib/mail/encodings/8bit.rb +31 -0
- data/vendor/mail/lib/mail/encodings/base64.rb +33 -0
- data/vendor/mail/lib/mail/encodings/binary.rb +31 -0
- data/vendor/mail/lib/mail/encodings/quoted_printable.rb +38 -0
- data/vendor/mail/lib/mail/encodings/transfer_encoding.rb +58 -0
- data/vendor/mail/lib/mail/envelope.rb +35 -0
- data/vendor/mail/lib/mail/field.rb +223 -0
- data/vendor/mail/lib/mail/field_list.rb +33 -0
- data/vendor/mail/lib/mail/fields.rb +35 -0
- data/vendor/mail/lib/mail/fields/bcc_field.rb +56 -0
- data/vendor/mail/lib/mail/fields/cc_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/comments_field.rb +41 -0
- data/vendor/mail/lib/mail/fields/common/address_container.rb +16 -0
- data/vendor/mail/lib/mail/fields/common/common_address.rb +125 -0
- data/vendor/mail/lib/mail/fields/common/common_date.rb +42 -0
- data/vendor/mail/lib/mail/fields/common/common_field.rb +50 -0
- data/vendor/mail/lib/mail/fields/common/common_message_id.rb +43 -0
- data/vendor/mail/lib/mail/fields/common/parameter_hash.rb +52 -0
- data/vendor/mail/lib/mail/fields/content_description_field.rb +19 -0
- data/vendor/mail/lib/mail/fields/content_disposition_field.rb +69 -0
- data/vendor/mail/lib/mail/fields/content_id_field.rb +63 -0
- data/vendor/mail/lib/mail/fields/content_location_field.rb +42 -0
- data/vendor/mail/lib/mail/fields/content_transfer_encoding_field.rb +50 -0
- data/vendor/mail/lib/mail/fields/content_type_field.rb +185 -0
- data/vendor/mail/lib/mail/fields/date_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/from_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/in_reply_to_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/keywords_field.rb +44 -0
- data/vendor/mail/lib/mail/fields/message_id_field.rb +83 -0
- data/vendor/mail/lib/mail/fields/mime_version_field.rb +53 -0
- data/vendor/mail/lib/mail/fields/optional_field.rb +13 -0
- data/vendor/mail/lib/mail/fields/received_field.rb +67 -0
- data/vendor/mail/lib/mail/fields/references_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/reply_to_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/resent_bcc_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/resent_cc_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/resent_date_field.rb +35 -0
- data/vendor/mail/lib/mail/fields/resent_from_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/resent_message_id_field.rb +34 -0
- data/vendor/mail/lib/mail/fields/resent_sender_field.rb +62 -0
- data/vendor/mail/lib/mail/fields/resent_to_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/return_path_field.rb +64 -0
- data/vendor/mail/lib/mail/fields/sender_field.rb +67 -0
- data/vendor/mail/lib/mail/fields/structured_field.rb +51 -0
- data/vendor/mail/lib/mail/fields/subject_field.rb +16 -0
- data/vendor/mail/lib/mail/fields/to_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/unstructured_field.rb +166 -0
- data/vendor/mail/lib/mail/header.rb +262 -0
- data/vendor/mail/lib/mail/mail.rb +234 -0
- data/vendor/mail/lib/mail/message.rb +1867 -0
- data/vendor/mail/lib/mail/network.rb +9 -0
- data/vendor/mail/lib/mail/network/delivery_methods/file_delivery.rb +40 -0
- data/vendor/mail/lib/mail/network/delivery_methods/sendmail.rb +62 -0
- data/vendor/mail/lib/mail/network/delivery_methods/smtp.rb +110 -0
- data/vendor/mail/lib/mail/network/delivery_methods/test_mailer.rb +40 -0
- data/vendor/mail/lib/mail/network/retriever_methods/imap.rb +18 -0
- data/vendor/mail/lib/mail/network/retriever_methods/pop3.rb +149 -0
- data/vendor/mail/lib/mail/parsers/address_lists.rb +64 -0
- data/vendor/mail/lib/mail/parsers/address_lists.treetop +19 -0
- data/vendor/mail/lib/mail/parsers/content_disposition.rb +387 -0
- data/vendor/mail/lib/mail/parsers/content_disposition.treetop +46 -0
- data/vendor/mail/lib/mail/parsers/content_location.rb +139 -0
- data/vendor/mail/lib/mail/parsers/content_location.treetop +20 -0
- data/vendor/mail/lib/mail/parsers/content_transfer_encoding.rb +162 -0
- data/vendor/mail/lib/mail/parsers/content_transfer_encoding.treetop +20 -0
- data/vendor/mail/lib/mail/parsers/content_type.rb +539 -0
- data/vendor/mail/lib/mail/parsers/content_type.treetop +58 -0
- data/vendor/mail/lib/mail/parsers/date_time.rb +114 -0
- data/vendor/mail/lib/mail/parsers/date_time.treetop +11 -0
- data/vendor/mail/lib/mail/parsers/envelope_from.rb +194 -0
- data/vendor/mail/lib/mail/parsers/envelope_from.treetop +32 -0
- data/vendor/mail/lib/mail/parsers/message_ids.rb +45 -0
- data/vendor/mail/lib/mail/parsers/message_ids.treetop +15 -0
- data/vendor/mail/lib/mail/parsers/mime_version.rb +144 -0
- data/vendor/mail/lib/mail/parsers/mime_version.treetop +19 -0
- data/vendor/mail/lib/mail/parsers/phrase_lists.rb +45 -0
- data/vendor/mail/lib/mail/parsers/phrase_lists.treetop +15 -0
- data/vendor/mail/lib/mail/parsers/received.rb +71 -0
- data/vendor/mail/lib/mail/parsers/received.treetop +11 -0
- data/vendor/mail/lib/mail/parsers/rfc2045.rb +464 -0
- data/vendor/mail/lib/mail/parsers/rfc2045.treetop +36 -0
- data/vendor/mail/lib/mail/parsers/rfc2822.rb +5318 -0
- data/vendor/mail/lib/mail/parsers/rfc2822.treetop +410 -0
- data/vendor/mail/lib/mail/parsers/rfc2822_obsolete.rb +3757 -0
- data/vendor/mail/lib/mail/parsers/rfc2822_obsolete.treetop +241 -0
- data/vendor/mail/lib/mail/part.rb +102 -0
- data/vendor/mail/lib/mail/parts_list.rb +34 -0
- data/vendor/mail/lib/mail/patterns.rb +30 -0
- data/vendor/mail/lib/mail/utilities.rb +181 -0
- data/vendor/mail/lib/mail/version.rb +10 -0
- data/vendor/mail/lib/mail/version_specific/ruby_1_8.rb +97 -0
- data/vendor/mail/lib/mail/version_specific/ruby_1_9.rb +87 -0
- data/vendor/mail/lib/tasks/corpus.rake +125 -0
- data/vendor/mail/lib/tasks/treetop.rake +10 -0
- data/vendor/mail/mail.gemspec +20 -0
- data/vendor/mail/reference/US ASCII Table.txt +130 -0
- data/vendor/mail/reference/rfc1035 Domain Implementation and Specification.txt +3083 -0
- data/vendor/mail/reference/rfc1049 Content-Type Header Field for Internet Messages.txt +451 -0
- data/vendor/mail/reference/rfc1344 Implications of MIME for Internet Mail Gateways.txt +586 -0
- data/vendor/mail/reference/rfc1345 Character Mnemonics & Character Sets.txt +5761 -0
- data/vendor/mail/reference/rfc1524 A User Agent Configuration Mechanism For Multimedia Mail Format Information.txt +675 -0
- data/vendor/mail/reference/rfc1652 SMTP Service Extension for 8bit-MIMEtransport.txt +339 -0
- data/vendor/mail/reference/rfc1892 Multipart Report .txt +227 -0
- data/vendor/mail/reference/rfc1893 Mail System Status Codes.txt +843 -0
- data/vendor/mail/reference/rfc2045 Multipurpose Internet Mail Extensions (1).txt +1739 -0
- data/vendor/mail/reference/rfc2046 Multipurpose Internet Mail Extensions (2).txt +2467 -0
- data/vendor/mail/reference/rfc2047 Multipurpose Internet Mail Extensions (3).txt +843 -0
- data/vendor/mail/reference/rfc2048 Multipurpose Internet Mail Extensions (4).txt +1180 -0
- data/vendor/mail/reference/rfc2049 Multipurpose Internet Mail Extensions (5).txt +1347 -0
- data/vendor/mail/reference/rfc2111 Content-ID and Message-ID URLs.txt +283 -0
- data/vendor/mail/reference/rfc2183 Content-Disposition Header Field.txt +675 -0
- data/vendor/mail/reference/rfc2231 MIME Parameter Value and Encoded Word Extensions.txt +563 -0
- data/vendor/mail/reference/rfc2387 MIME Multipart-Related Content-type.txt +563 -0
- data/vendor/mail/reference/rfc2821 Simple Mail Transfer Protocol.txt +3711 -0
- data/vendor/mail/reference/rfc2822 Internet Message Format.txt +2859 -0
- data/vendor/mail/reference/rfc3462 Reporting of Mail System Administrative Messages.txt +396 -0
- data/vendor/mail/reference/rfc3696 Checking and Transformation of Names.txt +898 -0
- data/vendor/mail/reference/rfc4155 The application-mbox Media Type.txt +502 -0
- data/vendor/mail/reference/rfc4234 Augmented BNF for Syntax Specifications: ABNF.txt +899 -0
- data/vendor/mail/reference/rfc822 Standard for the Format of ARPA Internet Text Messages.txt +2900 -0
- data/vendor/mail/spec/environment.rb +15 -0
- data/vendor/mail/spec/features/making_a_new_message.feature +14 -0
- data/vendor/mail/spec/features/steps/env.rb +6 -0
- data/vendor/mail/spec/features/steps/making_a_new_message_steps.rb +11 -0
- data/vendor/mail/spec/fixtures/attachments/basic_email.eml +31 -0
- data/vendor/mail/spec/fixtures/attachments/test.gif +0 -0
- data/vendor/mail/spec/fixtures/attachments/test.jpg +0 -0
- data/vendor/mail/spec/fixtures/attachments/test.pdf +0 -0
- data/vendor/mail/spec/fixtures/attachments/test.png +0 -0
- data/vendor/mail/spec/fixtures/attachments/test.tiff +0 -0
- data/vendor/mail/spec/fixtures/attachments/test.zip +0 -0
- data/vendor/mail/spec/fixtures/attachments//343/201/246/343/201/231/343/201/250.txt +2 -0
- data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_content_disposition.eml +29 -0
- data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_content_location.eml +32 -0
- data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_message_rfc822.eml +92 -0
- data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_only_email.eml +17 -0
- data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_pdf.eml +70 -0
- data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_with_encoded_name.eml +47 -0
- data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_with_quoted_filename.eml +60 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/cant_parse_from.eml +33 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_7-bit.eml +231 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_empty.eml +33 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_plain.eml +148 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_qp_with_space.eml +53 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_spam.eml +44 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_text-html.eml +50 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_with_8bits.eml +770 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_with_semi_colon.eml +269 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_x_uuencode.eml +79 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/empty_group_lists.eml +162 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/header_fields_with_empty_values.eml +33 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/missing_body.eml +16 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/missing_content_disposition.eml +43 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/multiple_content_types.eml +25 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email11.eml +34 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email12.eml +32 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email2.eml +114 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email4.eml +59 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email7.eml +66 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_encoded_stack_level_too_deep.eml +53 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_illegal_boundary.eml +58 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_mimepart_without_content_type.eml +94 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_multipart_mixed_quoted_boundary.eml +50 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_nested_attachment.eml +100 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_quoted_illegal_boundary.eml +58 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/sig_only_email.eml +29 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/two_from_in_message.eml +42 -0
- data/vendor/mail/spec/fixtures/emails/multi_charset/japanese.eml +9 -0
- data/vendor/mail/spec/fixtures/emails/multi_charset/japanese_attachment.eml +27 -0
- data/vendor/mail/spec/fixtures/emails/multi_charset/japanese_attachment_long_name.eml +44 -0
- data/vendor/mail/spec/fixtures/emails/multipart_report_emails/multi_address_bounce1.eml +179 -0
- data/vendor/mail/spec/fixtures/emails/multipart_report_emails/multi_address_bounce2.eml +179 -0
- data/vendor/mail/spec/fixtures/emails/multipart_report_emails/report_422.eml +98 -0
- data/vendor/mail/spec/fixtures/emails/multipart_report_emails/report_530.eml +97 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/basic_email.eml +31 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email.eml +14 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email10.eml +20 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email5.eml +19 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email6.eml +20 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email8.eml +47 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_bad_time.eml +62 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_double_at_in_header.eml +14 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_incorrect_header.eml +28 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_multiple_from.eml +30 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_quoted_with_0d0a.eml +14 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_reply.eml +32 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_simple.eml +11 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_string_in_date_field.eml +17 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_trailing_dot.eml +21 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_with_bad_date.eml +48 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_with_partially_quoted_subject.eml +14 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example01.eml +8 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example02.eml +9 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example03.eml +7 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example04.eml +7 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example05.eml +8 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example06.eml +10 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example07.eml +9 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example08.eml +12 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example09.eml +15 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example10.eml +15 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example11.eml +6 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example12.eml +8 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example13.eml +10 -0
- data/vendor/mail/spec/fixtures/emails/sample_output_multipart +0 -0
- data/vendor/mail/spec/mail/attachments_list_spec.rb +214 -0
- data/vendor/mail/spec/mail/body_spec.rb +385 -0
- data/vendor/mail/spec/mail/configuration_spec.rb +19 -0
- data/vendor/mail/spec/mail/core_extensions/string_spec.rb +62 -0
- data/vendor/mail/spec/mail/core_extensions_spec.rb +99 -0
- data/vendor/mail/spec/mail/elements/address_list_spec.rb +109 -0
- data/vendor/mail/spec/mail/elements/address_spec.rb +609 -0
- data/vendor/mail/spec/mail/elements/date_time_element_spec.rb +20 -0
- data/vendor/mail/spec/mail/elements/envelope_from_element_spec.rb +31 -0
- data/vendor/mail/spec/mail/elements/message_ids_element_spec.rb +43 -0
- data/vendor/mail/spec/mail/elements/phrase_list_spec.rb +22 -0
- data/vendor/mail/spec/mail/elements/received_element_spec.rb +34 -0
- data/vendor/mail/spec/mail/encoding_spec.rb +189 -0
- data/vendor/mail/spec/mail/encodings/base64_spec.rb +25 -0
- data/vendor/mail/spec/mail/encodings/quoted_printable_spec.rb +25 -0
- data/vendor/mail/spec/mail/encodings_spec.rb +664 -0
- data/vendor/mail/spec/mail/example_emails_spec.rb +303 -0
- data/vendor/mail/spec/mail/field_list_spec.rb +33 -0
- data/vendor/mail/spec/mail/field_spec.rb +198 -0
- data/vendor/mail/spec/mail/fields/bcc_field_spec.rb +89 -0
- data/vendor/mail/spec/mail/fields/cc_field_spec.rb +79 -0
- data/vendor/mail/spec/mail/fields/comments_field_spec.rb +25 -0
- data/vendor/mail/spec/mail/fields/common/address_container_spec.rb +18 -0
- data/vendor/mail/spec/mail/fields/common/common_address_spec.rb +132 -0
- data/vendor/mail/spec/mail/fields/common/common_date_spec.rb +25 -0
- data/vendor/mail/spec/mail/fields/common/common_field_spec.rb +69 -0
- data/vendor/mail/spec/mail/fields/common/common_message_id_spec.rb +30 -0
- data/vendor/mail/spec/mail/fields/common/parameter_hash_spec.rb +56 -0
- data/vendor/mail/spec/mail/fields/content_description_field_spec.rb +39 -0
- data/vendor/mail/spec/mail/fields/content_disposition_field_spec.rb +55 -0
- data/vendor/mail/spec/mail/fields/content_id_field_spec.rb +117 -0
- data/vendor/mail/spec/mail/fields/content_location_field_spec.rb +46 -0
- data/vendor/mail/spec/mail/fields/content_transfer_encoding_field_spec.rb +113 -0
- data/vendor/mail/spec/mail/fields/content_type_field_spec.rb +678 -0
- data/vendor/mail/spec/mail/fields/date_field_spec.rb +73 -0
- data/vendor/mail/spec/mail/fields/envelope_spec.rb +48 -0
- data/vendor/mail/spec/mail/fields/from_field_spec.rb +89 -0
- data/vendor/mail/spec/mail/fields/in_reply_to_field_spec.rb +62 -0
- data/vendor/mail/spec/mail/fields/keywords_field_spec.rb +66 -0
- data/vendor/mail/spec/mail/fields/message_id_field_spec.rb +147 -0
- data/vendor/mail/spec/mail/fields/mime_version_field_spec.rb +166 -0
- data/vendor/mail/spec/mail/fields/received_field_spec.rb +44 -0
- data/vendor/mail/spec/mail/fields/references_field_spec.rb +35 -0
- data/vendor/mail/spec/mail/fields/reply_to_field_spec.rb +67 -0
- data/vendor/mail/spec/mail/fields/resent_bcc_field_spec.rb +66 -0
- data/vendor/mail/spec/mail/fields/resent_cc_field_spec.rb +66 -0
- data/vendor/mail/spec/mail/fields/resent_date_field_spec.rb +39 -0
- data/vendor/mail/spec/mail/fields/resent_from_field_spec.rb +66 -0
- data/vendor/mail/spec/mail/fields/resent_message_id_field_spec.rb +24 -0
- data/vendor/mail/spec/mail/fields/resent_sender_field_spec.rb +58 -0
- data/vendor/mail/spec/mail/fields/resent_to_field_spec.rb +66 -0
- data/vendor/mail/spec/mail/fields/return_path_field_spec.rb +52 -0
- data/vendor/mail/spec/mail/fields/sender_field_spec.rb +58 -0
- data/vendor/mail/spec/mail/fields/structured_field_spec.rb +72 -0
- data/vendor/mail/spec/mail/fields/to_field_spec.rb +92 -0
- data/vendor/mail/spec/mail/fields/unstructured_field_spec.rb +134 -0
- data/vendor/mail/spec/mail/header_spec.rb +578 -0
- data/vendor/mail/spec/mail/mail_spec.rb +34 -0
- data/vendor/mail/spec/mail/message_spec.rb +1409 -0
- data/vendor/mail/spec/mail/mime_messages_spec.rb +435 -0
- data/vendor/mail/spec/mail/multipart_report_spec.rb +112 -0
- data/vendor/mail/spec/mail/network/delivery_methods/file_delivery_spec.rb +79 -0
- data/vendor/mail/spec/mail/network/delivery_methods/sendmail_spec.rb +125 -0
- data/vendor/mail/spec/mail/network/delivery_methods/smtp_spec.rb +133 -0
- data/vendor/mail/spec/mail/network/delivery_methods/test_mailer_spec.rb +57 -0
- data/vendor/mail/spec/mail/network/retriever_methods/pop3_spec.rb +180 -0
- data/vendor/mail/spec/mail/network_spec.rb +359 -0
- data/vendor/mail/spec/mail/parsers/address_lists_parser_spec.rb +15 -0
- data/vendor/mail/spec/mail/parsers/content_transfer_encoding_parser_spec.rb +72 -0
- data/vendor/mail/spec/mail/part_spec.rb +129 -0
- data/vendor/mail/spec/mail/parts_list_spec.rb +12 -0
- data/vendor/mail/spec/mail/round_tripping_spec.rb +44 -0
- data/vendor/mail/spec/mail/utilities_spec.rb +327 -0
- data/vendor/mail/spec/mail/version_specific/escape_paren_1_8_spec.rb +32 -0
- data/vendor/mail/spec/matchers/break_down_to.rb +35 -0
- data/vendor/mail/spec/spec_helper.rb +163 -0
- metadata +442 -0
data/vendor/mail/ROADMAP
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
=Mail Development Road Path
|
2
|
+
-------------------------------------------------------------
|
3
|
+
|
4
|
+
==Basic Email Handling
|
5
|
+
|
6
|
+
* Everything so far [DONE - ML]
|
7
|
+
|
8
|
+
* Address parsing working with all TMail tests passing [DONE - ML]
|
9
|
+
|
10
|
+
* All address fields handling addresses correctly [DONE - ML]
|
11
|
+
|
12
|
+
* Mail able to instantiate on any known header type, use method missing [DONE - ML]
|
13
|
+
|
14
|
+
* Keywords and comments fields working (low hanging fruit) [DONE - ML]
|
15
|
+
|
16
|
+
* Date parsing working [DONE - ML]
|
17
|
+
|
18
|
+
* Date fields handling dates correctly [DONE - ML]
|
19
|
+
|
20
|
+
* Trace fields decided on method to handle [DONE - ML]
|
21
|
+
|
22
|
+
* Trace fields parsing correctly [DONE - ML]
|
23
|
+
|
24
|
+
* All trace field functionality working [DONE - ML]
|
25
|
+
|
26
|
+
* Message ID fields handling correctly [DONE - ML]
|
27
|
+
|
28
|
+
* Message ID fields generating correctly [DONE - ML]
|
29
|
+
|
30
|
+
* Work out basic API on address fields [DONE - ML]
|
31
|
+
|
32
|
+
* All RFC 2822 example emails passing [DONE - ML]
|
33
|
+
|
34
|
+
* All TMail tests relating to RFC2822 passing
|
35
|
+
|
36
|
+
* All RFC 2822 obsolete example emails passing
|
37
|
+
|
38
|
+
==Multipart Email Handling
|
39
|
+
|
40
|
+
(need to break down into smaller steps when we get here)
|
41
|
+
|
42
|
+
* Initial stages of RFC 2045 implemented (content-type and 2046, 2047) [DONE - ML]
|
43
|
+
|
44
|
+
* Mime-Version field parsing [DONE - ML]
|
45
|
+
|
46
|
+
* Mime-Version field setting [DONE - ML]
|
47
|
+
|
48
|
+
* Content-ID field parsing [DONE - ML]
|
49
|
+
|
50
|
+
* Content-ID field setting [DONE - ML]
|
51
|
+
|
52
|
+
* Content-Description field parsing [DONE - ML]
|
53
|
+
|
54
|
+
* Content-Description field setting [DONE - ML]
|
55
|
+
|
56
|
+
* Content-Transfer-Encoding parsing [DONE - ML]
|
57
|
+
|
58
|
+
* Content-Transfer-Encoding setting [DONE - ML]
|
59
|
+
|
60
|
+
* Content-Type field parsing [DONE - ML]
|
61
|
+
|
62
|
+
* Content-Type field setting [DONE - ML]
|
63
|
+
|
64
|
+
* Multipart email support [DONE - ML]
|
65
|
+
|
66
|
+
* Reading multipart emails [DONE - ML]
|
67
|
+
|
68
|
+
* Creating multipart emails [DONE - ML]
|
69
|
+
|
70
|
+
* Multipart/Report reporting done [DONE - ML]
|
71
|
+
|
72
|
+
* Implement all helper methods on adding and deleting parts and attachments [DONE - ML]
|
73
|
+
|
74
|
+
==Encoding/Decoding
|
75
|
+
|
76
|
+
* Support for content-transport-encoding handling [DONE - ML] (base64)
|
77
|
+
|
78
|
+
* Handle non us-ascii in Subject, keywords, header fields in general [DONE - ML]
|
79
|
+
|
80
|
+
* handle encoding and decoding of multipart emails [DONE - ML] (base64)
|
81
|
+
|
82
|
+
==Basic Email Sending & Receiving
|
83
|
+
|
84
|
+
* Wrap up Net/SMTP [DONE - NF] (missing STMPS and Authentication Schemes support)
|
85
|
+
|
86
|
+
* Wrap up Net/POP3 [DONE - NF] (missing APOP support)
|
87
|
+
|
88
|
+
* Provide SMTP/POP3/IMAP default configurations for all known webmails
|
89
|
+
|
90
|
+
* Wrap up Net/IMAP (if we really want to...)
|
91
|
+
|
92
|
+
* Get a mbox parser and handler written
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.expand_path('../spec/environment', __FILE__)
|
2
|
+
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'spec/rake/spectask'
|
6
|
+
require 'cucumber/rake/task'
|
7
|
+
|
8
|
+
desc "Build a gem file"
|
9
|
+
task :build do
|
10
|
+
system "gem build mail.gemspec"
|
11
|
+
end
|
12
|
+
|
13
|
+
task :default => :spec
|
14
|
+
Cucumber::Rake::Task.new do |t|
|
15
|
+
t.cucumber_opts = "spec/features --format pretty"
|
16
|
+
end
|
17
|
+
|
18
|
+
# Spec::Rake::SpecTask.new(:rcov) do |t|
|
19
|
+
# t.spec_files = FileList['test/**/tc_*.rb', 'spec/**/*_spec.rb']
|
20
|
+
# t.rcov = true
|
21
|
+
# t.rcov_opts = t.rcov_opts << ['--exclude', '/Library,/opt,/System,/usr']
|
22
|
+
# end
|
23
|
+
|
24
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
25
|
+
t.warning = true
|
26
|
+
t.spec_files = FileList["#{File.dirname(__FILE__)}/spec/**/*_spec.rb"]
|
27
|
+
t.spec_opts = %w(--backtrace --diff --color)
|
28
|
+
t.libs << "#{File.dirname(__FILE__)}/spec"
|
29
|
+
t.libs << "#{File.dirname(__FILE__)}/spec/mail"
|
30
|
+
end
|
31
|
+
|
32
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
33
|
+
rdoc.rdoc_dir = 'rdoc'
|
34
|
+
rdoc.title = 'Mail'
|
35
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
36
|
+
rdoc.rdoc_files.include('README')
|
37
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
38
|
+
end
|
39
|
+
|
40
|
+
# load custom rake tasks
|
41
|
+
Dir["#{File.dirname(__FILE__)}/lib/tasks/**/*.rake"].sort.each { |ext| load ext }
|
@@ -0,0 +1,9 @@
|
|
1
|
+
== Not really in any order:
|
2
|
+
|
3
|
+
* Add multibyte handling to fields, if they get a multibyte string, try encoding it into
|
4
|
+
UTF-8 B first, if this fails, throw an error.
|
5
|
+
|
6
|
+
* Cleanup the treetop parsers......... do I _really_ need that many entrance files?
|
7
|
+
|
8
|
+
* Simplify the relationship of Headers and Fields. Doing too much of the Field work
|
9
|
+
in the Header class on instantiating fields. Header should just say "Field, do it!"
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Mail # :doc:
|
4
|
+
|
5
|
+
require 'date'
|
6
|
+
require 'uri'
|
7
|
+
require 'net/smtp'
|
8
|
+
require 'mime/types'
|
9
|
+
|
10
|
+
if RUBY_VERSION <= '1.8.6'
|
11
|
+
begin
|
12
|
+
require 'tlsmail'
|
13
|
+
rescue LoadError
|
14
|
+
raise "You need to install tlsmail if you are using ruby <= 1.8.6"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
if RUBY_VERSION >= "1.9.1"
|
19
|
+
require 'mail/version_specific/ruby_1_9'
|
20
|
+
RubyVer = Mail::Ruby19
|
21
|
+
else
|
22
|
+
require 'mail/version_specific/ruby_1_8'
|
23
|
+
RubyVer = Mail::Ruby18
|
24
|
+
end
|
25
|
+
|
26
|
+
require 'mail/version'
|
27
|
+
|
28
|
+
require 'mail/core_extensions/blank'
|
29
|
+
require 'mail/core_extensions/nil'
|
30
|
+
require 'mail/core_extensions/string'
|
31
|
+
|
32
|
+
require 'mail/patterns'
|
33
|
+
require 'mail/utilities'
|
34
|
+
require 'mail/configuration'
|
35
|
+
|
36
|
+
# Autoload mail send and receive classes.
|
37
|
+
require 'mail/network'
|
38
|
+
|
39
|
+
require 'mail/message'
|
40
|
+
require 'mail/part'
|
41
|
+
require 'mail/header'
|
42
|
+
require 'mail/parts_list'
|
43
|
+
require 'mail/attachments_list'
|
44
|
+
require 'mail/body'
|
45
|
+
require 'mail/field'
|
46
|
+
require 'mail/field_list'
|
47
|
+
|
48
|
+
require 'mail/envelope'
|
49
|
+
|
50
|
+
parsers = %w[ rfc2822_obsolete rfc2822 address_lists phrase_lists
|
51
|
+
date_time received message_ids envelope_from rfc2045
|
52
|
+
mime_version content_type content_disposition
|
53
|
+
content_transfer_encoding content_location ]
|
54
|
+
|
55
|
+
parsers.each do |parser|
|
56
|
+
begin
|
57
|
+
# Try requiring the pre-compiled ruby version first
|
58
|
+
require 'treetop/runtime'
|
59
|
+
require "mail/parsers/#{parser}"
|
60
|
+
rescue LoadError
|
61
|
+
# Otherwise, get treetop to compile and load it
|
62
|
+
require 'treetop/runtime'
|
63
|
+
require 'treetop/compiler'
|
64
|
+
Treetop.load(File.join(File.dirname(__FILE__)) + "/mail/parsers/#{parser}")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Autoload header field elements and transfer encodings.
|
69
|
+
require 'mail/elements'
|
70
|
+
require 'mail/encodings'
|
71
|
+
require 'mail/encodings/base64'
|
72
|
+
require 'mail/encodings/quoted_printable'
|
73
|
+
|
74
|
+
# Finally... require all the Mail.methods
|
75
|
+
require 'mail/mail'
|
76
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module Mail
|
2
|
+
class AttachmentsList < Array
|
3
|
+
|
4
|
+
def initialize(parts_list)
|
5
|
+
@parts_list = parts_list
|
6
|
+
parts_list.map { |p|
|
7
|
+
if p.content_type == "message/rfc822"
|
8
|
+
Mail.new(p.body).attachments
|
9
|
+
elsif p.parts.empty?
|
10
|
+
p if p.attachment?
|
11
|
+
else
|
12
|
+
p.attachments
|
13
|
+
end
|
14
|
+
}.flatten.compact.each { |a| self << a }
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
# Returns the attachment by filename or at index.
|
19
|
+
#
|
20
|
+
# mail.attachments['test.png'] = File.read('test.png')
|
21
|
+
# mail.attachments['test.jpg'] = File.read('test.jpg')
|
22
|
+
#
|
23
|
+
# mail.attachments['test.png'].filename #=> 'test.png'
|
24
|
+
# mail.attachments[1].filename #=> 'test.jpg'
|
25
|
+
def [](index_value)
|
26
|
+
if index_value.is_a?(Fixnum)
|
27
|
+
self.fetch(index_value)
|
28
|
+
else
|
29
|
+
self.select { |a| a.filename == index_value }.first
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def []=(name, value)
|
34
|
+
default_values = { :content_type => "#{set_mime_type(name)}; filename=\"#{name}\"",
|
35
|
+
:content_transfer_encoding => "#{guess_encoding}",
|
36
|
+
:content_disposition => "attachment; filename=\"#{name}\"" }
|
37
|
+
|
38
|
+
if value.is_a?(Hash)
|
39
|
+
|
40
|
+
default_values[:body] = value.delete(:content) if value[:content]
|
41
|
+
|
42
|
+
default_values[:body] = value.delete(:data) if value[:data]
|
43
|
+
|
44
|
+
encoding = value.delete(:transfer_encoding) || value.delete(:encoding)
|
45
|
+
if encoding
|
46
|
+
if Mail::Encodings.defined? encoding
|
47
|
+
default_values[:content_transfer_encoding] = encoding
|
48
|
+
else
|
49
|
+
raise "Do not know how to handle Content Transfer Encoding #{encoding}, please choose either quoted-printable or base64"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
if value[:mime_type]
|
54
|
+
default_values[:content_type] = value.delete(:mime_type)
|
55
|
+
@mime_type = MIME::Types[default_values[:content_type]].first
|
56
|
+
default_values[:content_transfer_encoding] = guess_encoding
|
57
|
+
end
|
58
|
+
|
59
|
+
hash = default_values.merge(value)
|
60
|
+
else
|
61
|
+
default_values[:body] = value
|
62
|
+
hash = default_values
|
63
|
+
end
|
64
|
+
|
65
|
+
if hash[:body].respond_to? :force_encoding and hash[:body].respond_to? :valid_encoding?
|
66
|
+
if not hash[:body].valid_encoding? and default_values[:content_transfer_encoding].downcase == "binary"
|
67
|
+
hash[:body].force_encoding("BINARY")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
attachment = Part.new(hash)
|
72
|
+
attachment.add_content_id(hash[:content_id])
|
73
|
+
|
74
|
+
@parts_list << attachment
|
75
|
+
end
|
76
|
+
|
77
|
+
# Uses the mime type to try and guess the encoding, if it is a binary type, or unknown, then we
|
78
|
+
# set it to binary, otherwise as set to plain text
|
79
|
+
def guess_encoding
|
80
|
+
if @mime_type && !@mime_type.binary?
|
81
|
+
"7bit"
|
82
|
+
else
|
83
|
+
"binary"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def set_mime_type(filename)
|
88
|
+
# Have to do this because MIME::Types is not Ruby 1.9 safe yet
|
89
|
+
if RUBY_VERSION >= '1.9'
|
90
|
+
new_file = String.new(filename).force_encoding(Encoding::BINARY)
|
91
|
+
ext = new_file.split('.'.force_encoding(Encoding::BINARY)).last
|
92
|
+
filename = "file.#{ext}".force_encoding('US-ASCII')
|
93
|
+
end
|
94
|
+
@mime_type = MIME::Types.type_for(filename).first
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
@@ -0,0 +1,287 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Mail
|
3
|
+
|
4
|
+
# = Body
|
5
|
+
#
|
6
|
+
# The body is where the text of the email is stored. Mail treats the body
|
7
|
+
# as a single object. The body itself has no information about boundaries
|
8
|
+
# used in the MIME standard, it just looks at it's content as either a single
|
9
|
+
# block of text, or (if it is a multipart message) as an array of blocks o text.
|
10
|
+
#
|
11
|
+
# A body has to be told to split itself up into a multipart message by calling
|
12
|
+
# #split with the correct boundary. This is because the body object has no way
|
13
|
+
# of knowing what the correct boundary is for itself (there could be many
|
14
|
+
# boundaries in a body in the case of a nested MIME text).
|
15
|
+
#
|
16
|
+
# Once split is called, Mail::Body will slice itself up on this boundary,
|
17
|
+
# assigning anything that appears before the first part to the preamble, and
|
18
|
+
# anything that appears after the closing boundary to the epilogue, then
|
19
|
+
# each part gets initialized into a Mail::Part object.
|
20
|
+
#
|
21
|
+
# The boundary that is used to split up the Body is also stored in the Body
|
22
|
+
# object for use on encoding itself back out to a string. You can
|
23
|
+
# overwrite this if it needs to be changed.
|
24
|
+
#
|
25
|
+
# On encoding, the body will return the preamble, then each part joined by
|
26
|
+
# the boundary, followed by a closing boundary string and then the epilogue.
|
27
|
+
class Body
|
28
|
+
|
29
|
+
def initialize(string = '')
|
30
|
+
@boundary = nil
|
31
|
+
@preamble = nil
|
32
|
+
@epilogue = nil
|
33
|
+
@charset = nil
|
34
|
+
@part_sort_order = [ "text/plain", "text/enriched", "text/html" ]
|
35
|
+
@parts = Mail::PartsList.new
|
36
|
+
if string.blank?
|
37
|
+
@raw_source = ''
|
38
|
+
else
|
39
|
+
# Do join first incase we have been given an Array in Ruby 1.9
|
40
|
+
if string.respond_to?(:join)
|
41
|
+
@raw_source = string.join('')
|
42
|
+
elsif string.respond_to?(:to_s)
|
43
|
+
@raw_source = string.to_s
|
44
|
+
else
|
45
|
+
raise "You can only assign a string or an object that responds_to? :join or :to_s to a body."
|
46
|
+
end
|
47
|
+
end
|
48
|
+
@encoding = (only_us_ascii? ? '7bit' : '8bit')
|
49
|
+
set_charset
|
50
|
+
end
|
51
|
+
|
52
|
+
# Matches this body with another body. Also matches the decoded value of this
|
53
|
+
# body with a string.
|
54
|
+
#
|
55
|
+
# Examples:
|
56
|
+
#
|
57
|
+
# body = Mail::Body.new('The body')
|
58
|
+
# body == body #=> true
|
59
|
+
#
|
60
|
+
# body = Mail::Body.new('The body')
|
61
|
+
# body == 'The body' #=> true
|
62
|
+
#
|
63
|
+
# body = Mail::Body.new("VGhlIGJvZHk=\n")
|
64
|
+
# body.encoding = 'base64'
|
65
|
+
# body == "The body" #=> true
|
66
|
+
def ==(other)
|
67
|
+
if other.class == String
|
68
|
+
self.decoded == other
|
69
|
+
else
|
70
|
+
super
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# Accepts a string and performs a regular expression against the decoded text
|
75
|
+
#
|
76
|
+
# Examples:
|
77
|
+
#
|
78
|
+
# body = Mail::Body.new('The body')
|
79
|
+
# body =~ /The/ #=> 0
|
80
|
+
#
|
81
|
+
# body = Mail::Body.new("VGhlIGJvZHk=\n")
|
82
|
+
# body.encoding = 'base64'
|
83
|
+
# body =~ /The/ #=> 0
|
84
|
+
def =~(regexp)
|
85
|
+
self.decoded =~ regexp
|
86
|
+
end
|
87
|
+
|
88
|
+
# Accepts a string and performs a regular expression against the decoded text
|
89
|
+
#
|
90
|
+
# Examples:
|
91
|
+
#
|
92
|
+
# body = Mail::Body.new('The body')
|
93
|
+
# body.match(/The/) #=> #<MatchData "The">
|
94
|
+
#
|
95
|
+
# body = Mail::Body.new("VGhlIGJvZHk=\n")
|
96
|
+
# body.encoding = 'base64'
|
97
|
+
# body.match(/The/) #=> #<MatchData "The">
|
98
|
+
def match(regexp)
|
99
|
+
self.decoded.match(regexp)
|
100
|
+
end
|
101
|
+
|
102
|
+
# Accepts anything that responds to #to_s and checks if it's a substring of the decoded text
|
103
|
+
#
|
104
|
+
# Examples:
|
105
|
+
#
|
106
|
+
# body = Mail::Body.new('The body')
|
107
|
+
# body.include?('The') #=> true
|
108
|
+
#
|
109
|
+
# body = Mail::Body.new("VGhlIGJvZHk=\n")
|
110
|
+
# body.encoding = 'base64'
|
111
|
+
# body.include?('The') #=> true
|
112
|
+
def include?(other)
|
113
|
+
self.decoded.include?(other.to_s)
|
114
|
+
end
|
115
|
+
|
116
|
+
# Allows you to set the sort order of the parts, overriding the default sort order.
|
117
|
+
# Defaults to 'text/plain', then 'text/enriched', then 'text/html' with any other content
|
118
|
+
# type coming after.
|
119
|
+
def set_sort_order(order)
|
120
|
+
@part_sort_order = order
|
121
|
+
end
|
122
|
+
|
123
|
+
# Allows you to sort the parts according to the default sort order, or the sort order you
|
124
|
+
# set with :set_sort_order.
|
125
|
+
#
|
126
|
+
# sort_parts! is also called from :encode, so there is no need for you to call this explicitly
|
127
|
+
def sort_parts!
|
128
|
+
@parts.each do |p|
|
129
|
+
p.body.set_sort_order(@part_sort_order)
|
130
|
+
@parts.sort!(@part_sort_order)
|
131
|
+
p.body.sort_parts!
|
132
|
+
end
|
133
|
+
# @parts.sort!(@part_sort_order)
|
134
|
+
end
|
135
|
+
|
136
|
+
# Returns the raw source that the body was initialized with, without
|
137
|
+
# any tampering
|
138
|
+
def raw_source
|
139
|
+
@raw_source
|
140
|
+
end
|
141
|
+
|
142
|
+
def get_best_encoding(target)
|
143
|
+
target_encoding = Mail::Encodings.get_encoding(target)
|
144
|
+
target_encoding.get_best_compatible(encoding, raw_source)
|
145
|
+
end
|
146
|
+
|
147
|
+
# Returns a body encoded using transfer_encoding. Multipart always uses an
|
148
|
+
# identiy encoding (i.e. no encoding).
|
149
|
+
# Calling this directly is not a good idea, but supported for compatibility
|
150
|
+
# TODO: Validate that preamble and epilogue are valid for requested encoding
|
151
|
+
def encoded(transfer_encoding = '8bit')
|
152
|
+
if multipart?
|
153
|
+
self.sort_parts!
|
154
|
+
encoded_parts = parts.map { |p| p.encoded }
|
155
|
+
([preamble] + encoded_parts).join(crlf_boundary) + end_boundary + epilogue.to_s
|
156
|
+
else
|
157
|
+
be = get_best_encoding(transfer_encoding)
|
158
|
+
dec = Mail::Encodings::get_encoding(encoding)
|
159
|
+
enc = Mail::Encodings::get_encoding(be)
|
160
|
+
if transfer_encoding == encoding and dec.nil?
|
161
|
+
# Cannot decode, so skip normalization
|
162
|
+
raw_source
|
163
|
+
else
|
164
|
+
# Decode then encode to normalize and allow transforming
|
165
|
+
# from base64 to Q-P and vice versa
|
166
|
+
enc.encode(dec.decode(raw_source))
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def decoded
|
172
|
+
if !Encodings.defined?(encoding)
|
173
|
+
raise UnknownEncodingType, "Don't know how to decode #{encoding}, please call #encoded and decode it yourself."
|
174
|
+
else
|
175
|
+
Encodings.get_encoding(encoding).decode(raw_source)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def to_s
|
180
|
+
decoded
|
181
|
+
end
|
182
|
+
|
183
|
+
def charset
|
184
|
+
@charset
|
185
|
+
end
|
186
|
+
|
187
|
+
def charset=( val )
|
188
|
+
@charset = val
|
189
|
+
end
|
190
|
+
|
191
|
+
def encoding(val = nil)
|
192
|
+
if val
|
193
|
+
self.encoding = val
|
194
|
+
else
|
195
|
+
@encoding
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
def encoding=( val )
|
200
|
+
if val == "text" || val.blank? then
|
201
|
+
val = "8bit"
|
202
|
+
end
|
203
|
+
@encoding = (val == "text") ? "8bit" : val
|
204
|
+
end
|
205
|
+
|
206
|
+
# Returns the preamble (any text that is before the first MIME boundary)
|
207
|
+
def preamble
|
208
|
+
@preamble
|
209
|
+
end
|
210
|
+
|
211
|
+
# Sets the preamble to a string (adds text before the first MIME boundary)
|
212
|
+
def preamble=( val )
|
213
|
+
@preamble = val
|
214
|
+
end
|
215
|
+
|
216
|
+
# Returns the epilogue (any text that is after the last MIME boundary)
|
217
|
+
def epilogue
|
218
|
+
@epilogue
|
219
|
+
end
|
220
|
+
|
221
|
+
# Sets the epilogue to a string (adds text after the last MIME boundary)
|
222
|
+
def epilogue=( val )
|
223
|
+
@epilogue = val
|
224
|
+
end
|
225
|
+
|
226
|
+
# Returns true if there are parts defined in the body
|
227
|
+
def multipart?
|
228
|
+
true unless parts.empty?
|
229
|
+
end
|
230
|
+
|
231
|
+
# Returns the boundary used by the body
|
232
|
+
def boundary
|
233
|
+
@boundary
|
234
|
+
end
|
235
|
+
|
236
|
+
# Allows you to change the boundary of this Body object
|
237
|
+
def boundary=( val )
|
238
|
+
@boundary = val
|
239
|
+
end
|
240
|
+
|
241
|
+
def parts
|
242
|
+
@parts
|
243
|
+
end
|
244
|
+
|
245
|
+
def <<( val )
|
246
|
+
if @parts
|
247
|
+
@parts << val
|
248
|
+
else
|
249
|
+
@parts = Mail::PartsList.new[val]
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
def split!(boundary)
|
254
|
+
self.boundary = boundary
|
255
|
+
parts = raw_source.split("--#{boundary}")
|
256
|
+
# Make the preamble equal to the preamble (if any)
|
257
|
+
self.preamble = parts[0].to_s.strip
|
258
|
+
# Make the epilogue equal to the epilogue (if any)
|
259
|
+
self.epilogue = parts[-1].to_s.sub('--', '').strip
|
260
|
+
parts[1...-1].to_a.each { |part| @parts << Mail::Part.new(part) }
|
261
|
+
self
|
262
|
+
end
|
263
|
+
|
264
|
+
def only_us_ascii?
|
265
|
+
raw_source.each_byte {|b| return false if (b == 0 || b > 127)}
|
266
|
+
true
|
267
|
+
end
|
268
|
+
|
269
|
+
def empty?
|
270
|
+
!!raw_source.to_s.empty?
|
271
|
+
end
|
272
|
+
|
273
|
+
private
|
274
|
+
|
275
|
+
def crlf_boundary
|
276
|
+
"\r\n\r\n--#{boundary}\r\n"
|
277
|
+
end
|
278
|
+
|
279
|
+
def end_boundary
|
280
|
+
"\r\n\r\n--#{boundary}--\r\n"
|
281
|
+
end
|
282
|
+
|
283
|
+
def set_charset
|
284
|
+
only_us_ascii? ? @charset = 'US-ASCII' : @charset = nil
|
285
|
+
end
|
286
|
+
end
|
287
|
+
end
|