rack-mail_exception 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem "tlsmail" if RUBY_VERSION <= '1.8.6'
|
4
|
+
gem "mime-types"
|
5
|
+
gem "treetop", ">= 1.4.5"
|
6
|
+
|
7
|
+
group :test do
|
8
|
+
gem "rcov"
|
9
|
+
gem "rake"
|
10
|
+
gem "bundler", "~> 0.9.10"
|
11
|
+
gem "cucumber"
|
12
|
+
gem "rspec"
|
13
|
+
gem "diff-lcs"
|
14
|
+
gem "ruby-debug" if RUBY_VERSION < '1.9' and RUBY_PLATFORM != 'java'
|
15
|
+
gem "ruby-debug19" if RUBY_VERSION > '1.9' and RUBY_PLATFORM != 'java'
|
16
|
+
gem "ZenTest"
|
17
|
+
end
|
@@ -0,0 +1,572 @@
|
|
1
|
+
= Mail
|
2
|
+
|
3
|
+
== Introduction
|
4
|
+
|
5
|
+
Mail is an internet library for Ruby that is designed to handle emails
|
6
|
+
generation, parsing and sending in a simple, rubyesque manner.
|
7
|
+
|
8
|
+
The purpose of this library is to provide a single point of access to handle
|
9
|
+
all email functions, including sending and receiving emails. All network
|
10
|
+
type actions are done through proxy methods to Net::SMTP, Net::POP3 etc.
|
11
|
+
|
12
|
+
Built from my experience with TMail, it is designed to be a pure ruby
|
13
|
+
implementation that makes generating, sending and parsing emails a no
|
14
|
+
brainer.
|
15
|
+
|
16
|
+
It is also designed form the ground up to work with Ruby 1.9. This is because
|
17
|
+
Ruby 1.9 handles text encodings much more magically than Ruby 1.8.x and so
|
18
|
+
these features have been taken full advantage of in this library allowing
|
19
|
+
Mail to handle a lot more messages more cleanly than TMail. Mail does run on
|
20
|
+
Ruby 1.8.x... it's just not as fun to code.
|
21
|
+
|
22
|
+
Finally, Mail has been designed with a very simple object oriented system
|
23
|
+
that really opens up the email messages you are parsing, if you know what
|
24
|
+
you are doing, you can fiddle with every last bit of your email directly.
|
25
|
+
|
26
|
+
== Compatibility
|
27
|
+
|
28
|
+
Mail is tested and works on the following platforms:
|
29
|
+
|
30
|
+
* jruby-1.4.0 [ [x86_64-java] ]
|
31
|
+
* ree-1.8.7-2010.01 [ x86_64 ]
|
32
|
+
* ruby-1.8.7-p249 [ x86_64 ]
|
33
|
+
* ruby-1.9.1-head [ x86_64 ] (10 April 2010)
|
34
|
+
* ruby-1.9.2-head [ x86_64 ] (10 April 2010)
|
35
|
+
|
36
|
+
Mail seems to work fine on JRuby as well, however there is some weird QP
|
37
|
+
problem that only shows up while running the specs, running it directly
|
38
|
+
works fine.... weird. Any jRuby gurus who want to help out, please do.
|
39
|
+
|
40
|
+
== Discussion
|
41
|
+
|
42
|
+
If you want to discuss mail with like minded individuals, please subscribe to
|
43
|
+
the Google Group http://groups.google.com/group/mail-ruby
|
44
|
+
|
45
|
+
== Current Capabilities of Mail
|
46
|
+
|
47
|
+
* RFC2822 Support, Reading and Writing
|
48
|
+
* RFC2045-2049 Support for multipart emails
|
49
|
+
* Support for creating multipart alternate emails
|
50
|
+
* Support for reading multipart/report emails & getting details from such
|
51
|
+
* Support for multibyte emails - needs quite a lot of work and testing
|
52
|
+
* Wrappers for File, Net/POP3, Net/SMTP
|
53
|
+
* Auto encoding of non US-ASCII header fields
|
54
|
+
* Auto encoding of non US-ASCII bodies
|
55
|
+
|
56
|
+
Mail is RFC2822 compliant now, that is, it can parse and generate valid US-ASCII
|
57
|
+
emails. There are a few obsoleted syntax emails that it will have problems with, but
|
58
|
+
it also is quite robust, meaning, if it finds something it doesn't understand it will
|
59
|
+
not crash, instead, it will skip the problem and keep parsing. In the case of a header
|
60
|
+
it doesn't understand, it will initialise the header as an optional unstructured
|
61
|
+
field and continue parsing.
|
62
|
+
|
63
|
+
This means Mail won't (ever) crunch your data (I think).
|
64
|
+
|
65
|
+
You can also create MIME emails. There are helper methods for making a
|
66
|
+
multipart/alternate email for text/plain and text/html (the most common pair)
|
67
|
+
and you can manually create any other type of MIME email.
|
68
|
+
|
69
|
+
== Roadmap
|
70
|
+
|
71
|
+
Next TODO:
|
72
|
+
|
73
|
+
* Improve MIME support for character sets in headers, currently works, mostly, needs
|
74
|
+
refinement.
|
75
|
+
* Add IMAP wrapper
|
76
|
+
|
77
|
+
== Testing Policy
|
78
|
+
|
79
|
+
Basically... we do BDD on Mail. No method gets written in Mail without a
|
80
|
+
corresponding or covering spec. We expect as a minimum 100% coverage
|
81
|
+
measured by RCov. While this is not perfect by any measure, it is pretty
|
82
|
+
good. Additionally, all functional tests from TMail are to be passing before
|
83
|
+
the gem gets released.
|
84
|
+
|
85
|
+
It also means you can be sure Mail will behave correctly.
|
86
|
+
|
87
|
+
== API Policy
|
88
|
+
|
89
|
+
No API removals within a single point release. All removals to be depreciated with
|
90
|
+
warnings for at least one MINOR point release before removal.
|
91
|
+
|
92
|
+
Also, all private or protected methods to be declared as such - though this is still I/P.
|
93
|
+
|
94
|
+
== Installation
|
95
|
+
|
96
|
+
Installation is fairly simple, I host mail on gemcutter, so you can just do:
|
97
|
+
|
98
|
+
# gem install mail
|
99
|
+
|
100
|
+
if you are on gemcutter, if you aren't, you can by doing:
|
101
|
+
|
102
|
+
# gem install gemcutter
|
103
|
+
# gem tumble
|
104
|
+
# gem install mail
|
105
|
+
|
106
|
+
Warning though, the above will change your first gem repository to gemcutter, this
|
107
|
+
may or may not be a problem for you.
|
108
|
+
|
109
|
+
If you want to install mail manually, you can download the gem from github and do:
|
110
|
+
|
111
|
+
# gem install mail-2.2.0.gem
|
112
|
+
|
113
|
+
== Encodings
|
114
|
+
|
115
|
+
If you didn't know, handling encodings in Emails is not as straight forward as you
|
116
|
+
would hope.
|
117
|
+
|
118
|
+
I have tried to simplify it some:
|
119
|
+
|
120
|
+
1. All objects that can render into an email, have an :encoded method. Encoded will
|
121
|
+
return the object as a complete string ready to send in the mail system, that is,
|
122
|
+
it will include the header field and value and CRLF at the end and wrapped as
|
123
|
+
needed.
|
124
|
+
|
125
|
+
2. All objects that can render into an email, have a :decoded method. Decoded will
|
126
|
+
return the object's "value" only as a string. This means it will not include
|
127
|
+
the header fields (like 'To:' or 'Subject:').
|
128
|
+
|
129
|
+
3. By default, calling :to_s on a container object will call it's encoded method, while
|
130
|
+
:to_s on a field object will call it's decoded method. So calling :to_s on a Mail
|
131
|
+
object will return the mail, all encoded ready to send, while calling :to_s on the
|
132
|
+
From field or the body will return the decoded value of the object. The header object
|
133
|
+
of Mail is considered a container. If you are in doubt, call :encoded, or :decoded
|
134
|
+
explicitly, this is safer if you are not sure.
|
135
|
+
|
136
|
+
4. Structured fields that have parameter values that can be encoded (e.g. Content-Type) will
|
137
|
+
provide decoded parameter values when you call the parameter names as methods against
|
138
|
+
the object.
|
139
|
+
|
140
|
+
5. Structured fields that have parameter values that can be encoded (e.g. Content-Type) will
|
141
|
+
provide encoded parameter values when you call the parameter names through the
|
142
|
+
object.parameters['<parameter_name>'] method call.
|
143
|
+
|
144
|
+
== Contributing
|
145
|
+
|
146
|
+
Please do! Contributing is easy in Mail:
|
147
|
+
|
148
|
+
1. Check the Reference RFCs, they are in the References directory, so no excuses.
|
149
|
+
2. Open a ticket on github, maybe someone else has the problem too
|
150
|
+
3. Make a fork of my github repository
|
151
|
+
4. Make a spec driven change to the code base
|
152
|
+
5. Make sure it works and all specs pass, on Ruby versions 1.8.6, 1.8.7 and 1.9
|
153
|
+
6. Update the README if needed to reflect your change / addition
|
154
|
+
7. With all specs passing push your changes back to your fork
|
155
|
+
8. Send me a pull request
|
156
|
+
|
157
|
+
== Usage
|
158
|
+
|
159
|
+
All major mail functions should be able to happen from the Mail::module.
|
160
|
+
So, you should be able to just "require 'mail'" to get started.
|
161
|
+
|
162
|
+
=== Making an email
|
163
|
+
|
164
|
+
require 'mail'
|
165
|
+
|
166
|
+
mail = Mail.new do
|
167
|
+
from 'mikel@test.lindsaar.net'
|
168
|
+
to 'you@test.lindsaar.net'
|
169
|
+
subject 'This is a test email'
|
170
|
+
body File.read('body.txt')
|
171
|
+
end
|
172
|
+
|
173
|
+
mail.to_s #=> "From: mikel@test.lindsaar.net\r\nTo: you@...
|
174
|
+
|
175
|
+
=== Making an email, have it your way:
|
176
|
+
|
177
|
+
require 'mail'
|
178
|
+
|
179
|
+
mail = Mail.new do
|
180
|
+
body File.read('body.txt')
|
181
|
+
end
|
182
|
+
|
183
|
+
mail['from'] = 'mikel@test.lindsaar.net'
|
184
|
+
mail[:to] = 'you@test.lindsaar.net'
|
185
|
+
mail.subject = 'This is a test email'
|
186
|
+
|
187
|
+
mail.to_s #=> "From: mikel@test.lindsaar.net\r\nTo: you@...
|
188
|
+
|
189
|
+
=== Don't Worry About Message IDs:
|
190
|
+
|
191
|
+
require 'mail'
|
192
|
+
|
193
|
+
mail = Mail.new do
|
194
|
+
to 'you@test.lindsaar.net'
|
195
|
+
body 'Some simple body'
|
196
|
+
end
|
197
|
+
|
198
|
+
mail.to_s =~ /Message\-ID: <[\d\w_]+@.+.mail/ #=> 27
|
199
|
+
|
200
|
+
Mail will automatically add a Message-ID field if it is missing and
|
201
|
+
give it a unique, random Message-ID along the lines of:
|
202
|
+
|
203
|
+
<4a7ff76d7016_13a81ab802e1@local.fqdn.mail>
|
204
|
+
|
205
|
+
=== Or do worry about Message-IDs:
|
206
|
+
|
207
|
+
require 'mail'
|
208
|
+
|
209
|
+
mail = Mail.new do
|
210
|
+
to 'you@test.lindsaar.net'
|
211
|
+
message_id '<ThisIsMyMessageId@some.domain.com>'
|
212
|
+
body 'Some simple body'
|
213
|
+
end
|
214
|
+
|
215
|
+
mail.to_s =~ /Message\-ID: <ThisIsMyMessageId@some.domain.com>/ #=> 27
|
216
|
+
|
217
|
+
Mail will take the message_id you assign to it trusting that you know
|
218
|
+
what you are doing.
|
219
|
+
|
220
|
+
=== Sending an email:
|
221
|
+
|
222
|
+
Mail defaults to sending via SMTP to local host port 25. If you have a
|
223
|
+
sendmail or postfix daemon running on on this port, sending email is as
|
224
|
+
easy as:
|
225
|
+
|
226
|
+
Mail.deliver do
|
227
|
+
from 'me@test.lindsaar.net'
|
228
|
+
to 'you@test.lindsaar.net'
|
229
|
+
subject 'Here is the image you wanted'
|
230
|
+
body File.read('body.txt')
|
231
|
+
add_file '/full/path/to/somefile.png'
|
232
|
+
end
|
233
|
+
|
234
|
+
or
|
235
|
+
|
236
|
+
mail = Mail.new do
|
237
|
+
from 'me@test.lindsaar.net'
|
238
|
+
to 'you@test.lindsaar.net'
|
239
|
+
subject 'Here is the image you wanted'
|
240
|
+
body File.read('body.txt')
|
241
|
+
add_file {:filename => 'somefile.png', :content => File.read('/somefile.png')}
|
242
|
+
end
|
243
|
+
|
244
|
+
mail.deliver!
|
245
|
+
|
246
|
+
Sending via sendmail can be done like so:
|
247
|
+
|
248
|
+
mail = Mail.new do
|
249
|
+
from 'me@test.lindsaar.net'
|
250
|
+
to 'you@test.lindsaar.net'
|
251
|
+
subject 'Here is the image you wanted'
|
252
|
+
body File.read('body.txt')
|
253
|
+
add_file {:filename => 'somefile.png', :content => File.read('/somefile.png')}
|
254
|
+
end
|
255
|
+
|
256
|
+
mail.delivery_method :sendmail
|
257
|
+
|
258
|
+
mail.deliver
|
259
|
+
|
260
|
+
mail.deliver!
|
261
|
+
|
262
|
+
|
263
|
+
=== Getting emails from a pop server:
|
264
|
+
|
265
|
+
The most recent email:
|
266
|
+
|
267
|
+
Mail.defaults do
|
268
|
+
retriever_method :pop3, { :address => "pop.gmail.com",
|
269
|
+
:port => 995,
|
270
|
+
:user_name => '<username>',
|
271
|
+
:password => '<password>',
|
272
|
+
:enable_ssl => true }
|
273
|
+
end
|
274
|
+
|
275
|
+
Mail.all #=> Returns an array of all emails
|
276
|
+
Mail.first #=> Returns the first unread email
|
277
|
+
Mail.last #=> Returns the first unread email
|
278
|
+
|
279
|
+
The first 10 emails sorted by date in ascending order:
|
280
|
+
|
281
|
+
require 'mail'
|
282
|
+
|
283
|
+
Mail.defaults do
|
284
|
+
retriever_method :pop3, { :address => "pop.gmail.com",
|
285
|
+
:port => 995,
|
286
|
+
:user_name => '<username>',
|
287
|
+
:password => '<password>',
|
288
|
+
:enable_ssl => true }
|
289
|
+
end
|
290
|
+
|
291
|
+
emails = Mail.find(:what => :first, :count => 10, :order => :asc)
|
292
|
+
emails.length #=> 10
|
293
|
+
|
294
|
+
Or even all emails:
|
295
|
+
|
296
|
+
Mail.defaults do
|
297
|
+
retriever_method :pop3, { :address => "pop.gmail.com",
|
298
|
+
:port => 995,
|
299
|
+
:user_name => '<username>',
|
300
|
+
:password => '<password>',
|
301
|
+
:enable_ssl => true }
|
302
|
+
end
|
303
|
+
|
304
|
+
emails = Mail.all
|
305
|
+
|
306
|
+
emails.length #=> LOTS!
|
307
|
+
|
308
|
+
=== Reading an Email
|
309
|
+
|
310
|
+
require 'mail'
|
311
|
+
|
312
|
+
mail = Mail.read('/path/to/message.eml')
|
313
|
+
|
314
|
+
mail.envelope.from #=> 'mikel@test.lindsaar.net'
|
315
|
+
mail.from.addresses #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
|
316
|
+
mail.sender.address #=> 'mikel@test.lindsaar.net'
|
317
|
+
mail.to #=> 'bob@test.lindsaar.net'
|
318
|
+
mail.cc #=> 'sam@test.lindsaar.net'
|
319
|
+
mail.subject #=> "This is the subject"
|
320
|
+
mail.date.to_s #=> '21 Nov 1997 09:55:06 -0600'
|
321
|
+
mail.message_id #=> '<4D6AA7EB.6490534@xxx.xxx>'
|
322
|
+
mail.body.decoded #=> 'This is the body of the email...
|
323
|
+
|
324
|
+
Many more methods available.
|
325
|
+
|
326
|
+
=== Reading a Multipart Email
|
327
|
+
|
328
|
+
require 'mail'
|
329
|
+
|
330
|
+
mail = Mail.read('multipart_email')
|
331
|
+
|
332
|
+
mail.multipart? #=> true
|
333
|
+
mail.parts.length #=> 2
|
334
|
+
mail.preamble #=> "Text before the first part"
|
335
|
+
mail.epilogue #=> "Text after the last part"
|
336
|
+
mail.parts.map { |p| p.content_type } #=> ['text/plain', 'application/pdf']
|
337
|
+
mail.parts.map { |p| p.class } #=> [Mail::Message, Mail::Message]
|
338
|
+
mail.parts[0].content_type_parameters #=> {'charset' => 'ISO-8859-1'}
|
339
|
+
mail.parts[1].content_type_parameters #=> {'name' => 'my.pdf'}
|
340
|
+
|
341
|
+
Mail generates a tree of parts. Each message has many or no parts. Each part
|
342
|
+
is another message which can have many or no parts.
|
343
|
+
|
344
|
+
A message will only have parts if it is a multipart/mixed or related/mixed
|
345
|
+
content type and has a boundary defined.
|
346
|
+
|
347
|
+
=== Writing and sending a multipart/alternative (html and text) email
|
348
|
+
|
349
|
+
Mail makes some basic assumptions and makes doing the common thing as
|
350
|
+
simple as possible.... (asking a lot from a mail library)
|
351
|
+
|
352
|
+
require 'mail'
|
353
|
+
|
354
|
+
mail = Mail.deliver do
|
355
|
+
to 'nicolas@test.lindsaar.net.au'
|
356
|
+
from 'Mikel Lindsaar <mikel@test.lindsaar.net.au>'
|
357
|
+
subject 'First multipart email sent with Mail'
|
358
|
+
text_part do
|
359
|
+
body 'This is plain text'
|
360
|
+
end
|
361
|
+
html_part do
|
362
|
+
content_type 'text/html; charset=UTF-8'
|
363
|
+
body '<h1>This is HTML</h1>'
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
Mail then delivers the email at the end of the block and returns the
|
368
|
+
resulting Mail::Message object, which you can then inspect if you
|
369
|
+
so desire...
|
370
|
+
|
371
|
+
puts mail.to_s #=>
|
372
|
+
|
373
|
+
To: nicolas@test.lindsaar.net.au
|
374
|
+
From: Mikel Lindsaar <mikel@test.lindsaar.net.au>
|
375
|
+
Subject: First multipart email sent with Mail
|
376
|
+
Content-Type: multipart/alternative;
|
377
|
+
boundary=--==_mimepart_4a914f0c911be_6f0f1ab8026659
|
378
|
+
Message-ID: <4a914f12ac7e_6f0f1ab80267d1@baci.local.mail>
|
379
|
+
Date: Mon, 24 Aug 2009 00:15:46 +1000
|
380
|
+
Mime-Version: 1.0
|
381
|
+
Content-Transfer-Encoding: 7bit
|
382
|
+
|
383
|
+
|
384
|
+
----==_mimepart_4a914f0c911be_6f0f1ab8026659
|
385
|
+
Content-ID: <4a914f12c8c4_6f0f1ab80268d6@baci.local.mail>
|
386
|
+
Date: Mon, 24 Aug 2009 00:15:46 +1000
|
387
|
+
Mime-Version: 1.0
|
388
|
+
Content-Type: text/plain
|
389
|
+
Content-Transfer-Encoding: 7bit
|
390
|
+
|
391
|
+
This is plain text
|
392
|
+
----==_mimepart_4a914f0c911be_6f0f1ab8026659
|
393
|
+
Content-Type: text/html; charset=UTF-8
|
394
|
+
Content-ID: <4a914f12cf86_6f0f1ab802692c@baci.local.mail>
|
395
|
+
Date: Mon, 24 Aug 2009 00:15:46 +1000
|
396
|
+
Mime-Version: 1.0
|
397
|
+
Content-Transfer-Encoding: 7bit
|
398
|
+
|
399
|
+
<h1>This is HTML</h1>
|
400
|
+
----==_mimepart_4a914f0c911be_6f0f1ab8026659--
|
401
|
+
|
402
|
+
Mail inserts the content transfer encoding, the mime version,
|
403
|
+
the content-id's and handles the content-type and boundary.
|
404
|
+
|
405
|
+
Mail assumes that if your text in the body is only us-ascii, that your
|
406
|
+
transfer encoding is 7bit and it is text/plain. You can override this
|
407
|
+
by explicitly declaring it.
|
408
|
+
|
409
|
+
=== Making Multipart/Alternate, without a block
|
410
|
+
|
411
|
+
You don't have to use a block with the text and html part included, you
|
412
|
+
can just do it declaratively. However, you need to add Mail::Parts to
|
413
|
+
an email, not Mail::Messages.
|
414
|
+
|
415
|
+
require 'mail'
|
416
|
+
|
417
|
+
mail = Mail.new do
|
418
|
+
to 'nicolas@test.lindsaar.net.au'
|
419
|
+
from 'Mikel Lindsaar <mikel@test.lindsaar.net.au>'
|
420
|
+
subject 'First multipart email sent with Mail'
|
421
|
+
end
|
422
|
+
|
423
|
+
text_part = Mail::Part.new do
|
424
|
+
body 'This is plain text'
|
425
|
+
end
|
426
|
+
|
427
|
+
html_part = Mail::Part.new do
|
428
|
+
content_type 'text/html; charset=UTF-8'
|
429
|
+
body '<h1>This is HTML</h1>'
|
430
|
+
end
|
431
|
+
|
432
|
+
mail.text_part = text_part
|
433
|
+
mail.html_part = html_part
|
434
|
+
|
435
|
+
Results in the same email as done using the block form
|
436
|
+
|
437
|
+
=== Getting error reports from an email:
|
438
|
+
|
439
|
+
require 'mail'
|
440
|
+
|
441
|
+
@mail = Mail.read('/path/to/bounce_message.eml')
|
442
|
+
|
443
|
+
@mail.bounced? #=> true
|
444
|
+
@mail.final_recipient #=> rfc822;mikel@dont.exist.com
|
445
|
+
@mail.action #=> failed
|
446
|
+
@mail.error_status #=> 5.5.0
|
447
|
+
@mail.diagnostic_code #=> smtp;550 Requested action not taken: mailbox unavailable
|
448
|
+
@mail.retryable? #=> false
|
449
|
+
|
450
|
+
=== Attaching and Detaching Files
|
451
|
+
|
452
|
+
require 'mail'
|
453
|
+
|
454
|
+
You can just read the file off an absolute path, Mail will try
|
455
|
+
to guess the mime_type and will encode the file in Base64 for you.
|
456
|
+
|
457
|
+
@mail = Mail.new
|
458
|
+
@mail.add_file("/path/to/file.jpg")
|
459
|
+
@mail.parts.first.attachment? #=> true
|
460
|
+
@mail.parts.first.content_transfer_encoding.to_s #=> 'base64'
|
461
|
+
@mail.attachments.first.mime_type #=> 'image/jpg'
|
462
|
+
@mail.attachments.first.filename #=> 'file.jpg'
|
463
|
+
@mail.attachments.first.decoded == File.read('/path/to/file.jpg') #=> true
|
464
|
+
|
465
|
+
Or You can pass in file_data and give it a filename, again, mail
|
466
|
+
will try and guess the mime_type for you.
|
467
|
+
|
468
|
+
@mail = Mail.new
|
469
|
+
@mail.attachments['myfile.pdf'] = File.read('path/to/myfile.pdf')
|
470
|
+
@mail.parts.first.attachment? #=> true
|
471
|
+
@mail.attachments.first.mime_type #=> 'application/pdf'
|
472
|
+
@mail.attachments.first.decoded == File.read('path/to/myfile.pdf') #=> true
|
473
|
+
|
474
|
+
You can also override the guessed MIME media type if you really know better
|
475
|
+
than mail (this should be rarely needed)
|
476
|
+
|
477
|
+
@mail = Mail.new
|
478
|
+
file_data = File.read('path/to/myfile.pdf')
|
479
|
+
@mail.attachments['myfile.pdf'] = { :mime_type => 'application/x-pdf',
|
480
|
+
:content => File.read('path/to/myfile.pdf') }
|
481
|
+
@mail.parts.first.mime_type #=> 'application/x-pdf'
|
482
|
+
|
483
|
+
Of course... Mail will round trip an attachment as well
|
484
|
+
|
485
|
+
@mail = Mail.new do
|
486
|
+
to 'nicolas@test.lindsaar.net.au'
|
487
|
+
from 'Mikel Lindsaar <mikel@test.lindsaar.net.au>'
|
488
|
+
subject 'First multipart email sent with Mail'
|
489
|
+
text_part do
|
490
|
+
body 'Here is the attachment you wanted'
|
491
|
+
end
|
492
|
+
html_part do
|
493
|
+
content_type 'text/html; charset=UTF-8'
|
494
|
+
body '<h1>Funky Title</h1><p>Here is the attachment you wanted</p>'
|
495
|
+
end
|
496
|
+
add_file '/path/to/myfile.pdf'
|
497
|
+
end
|
498
|
+
|
499
|
+
@round_tripped_mail = Mail.new(@mail.encoded)
|
500
|
+
|
501
|
+
@round_tripped_mail.attachments.length #=> 1
|
502
|
+
@round_tripped_mail.attachments.first.filename #=> 'myfile.pdf'
|
503
|
+
|
504
|
+
== Using Mail with Testing or Spec'ing Libraries
|
505
|
+
|
506
|
+
If mail is part of your system, you'll need a way to test it without actually
|
507
|
+
sending emails, the TestMailer can do this for you.
|
508
|
+
|
509
|
+
require 'mail'
|
510
|
+
=> true
|
511
|
+
Mail.defaults do
|
512
|
+
delivery_method :test
|
513
|
+
end
|
514
|
+
=> #<Mail::Configuration:0x19345a8 @delivery_method=Mail::TestMailer>
|
515
|
+
Mail::TestMailer.deliveries
|
516
|
+
=> []
|
517
|
+
Mail.deliver do
|
518
|
+
to 'mikel@me.com'
|
519
|
+
from 'you@you.com'
|
520
|
+
subject 'testing'
|
521
|
+
body 'hello'
|
522
|
+
end
|
523
|
+
=> #<Mail::Message:0x19284ec ...
|
524
|
+
Mail::TestMailer.deliveries.length
|
525
|
+
=> 1
|
526
|
+
Mail::TestMailer.deliveries.first
|
527
|
+
=> #<Mail::Message:0x19284ec ...
|
528
|
+
Mail::TestMailer.deliveries.clear
|
529
|
+
=> []
|
530
|
+
|
531
|
+
== Excerpts from TREC Spam Corpus 2005
|
532
|
+
|
533
|
+
The spec fixture files in spec/fixtures/emails/from_trec_2005 are from the
|
534
|
+
2005 TREC Public Spam Corpus. They remain copyrighted under the terms of
|
535
|
+
that project and license agreement. They are used in this project to verify
|
536
|
+
and describe the development of this email parser implementation.
|
537
|
+
|
538
|
+
http://plg.uwaterloo.ca/~gvcormac/treccorpus/
|
539
|
+
|
540
|
+
They are used as allowed by 'Permitted Uses, Clause 3':
|
541
|
+
|
542
|
+
"Small excerpts of the information may be displayed to others
|
543
|
+
or published in a scientific or technical context, solely for
|
544
|
+
the purpose of describing the research and development and
|
545
|
+
related issues."
|
546
|
+
|
547
|
+
-- http://plg.uwaterloo.ca/~gvcormac/treccorpus/
|
548
|
+
|
549
|
+
== License:
|
550
|
+
|
551
|
+
(The MIT License)
|
552
|
+
|
553
|
+
Copyright (c) 2009
|
554
|
+
|
555
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
556
|
+
a copy of this software and associated documentation files (the
|
557
|
+
'Software'), to deal in the Software without restriction, including
|
558
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
559
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
560
|
+
permit persons to whom the Software is furnished to do so, subject to
|
561
|
+
the following conditions:
|
562
|
+
|
563
|
+
The above copyright notice and this permission notice shall be
|
564
|
+
included in all copies or substantial portions of the Software.
|
565
|
+
|
566
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
567
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
568
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
569
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
570
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
571
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
572
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|