rack-mail_exception 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (321) hide show
  1. data/.document +5 -0
  2. data/.gitignore +22 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +38 -0
  5. data/Rakefile +56 -0
  6. data/VERSION +1 -0
  7. data/lib/rack/mail_exception.rb +103 -0
  8. data/test/helper.rb +13 -0
  9. data/test/test_rack_mail_exception.rb +93 -0
  10. data/vendor/mail/.bundle/config +2 -0
  11. data/vendor/mail/CHANGELOG.rdoc +370 -0
  12. data/vendor/mail/Dependencies.txt +3 -0
  13. data/vendor/mail/Gemfile +17 -0
  14. data/vendor/mail/README.rdoc +572 -0
  15. data/vendor/mail/ROADMAP +92 -0
  16. data/vendor/mail/Rakefile +41 -0
  17. data/vendor/mail/TODO.rdoc +9 -0
  18. data/vendor/mail/lib/mail.rb +76 -0
  19. data/vendor/mail/lib/mail/attachments_list.rb +99 -0
  20. data/vendor/mail/lib/mail/body.rb +287 -0
  21. data/vendor/mail/lib/mail/configuration.rb +67 -0
  22. data/vendor/mail/lib/mail/core_extensions/blank.rb +26 -0
  23. data/vendor/mail/lib/mail/core_extensions/nil.rb +11 -0
  24. data/vendor/mail/lib/mail/core_extensions/string.rb +27 -0
  25. data/vendor/mail/lib/mail/elements.rb +14 -0
  26. data/vendor/mail/lib/mail/elements/address.rb +306 -0
  27. data/vendor/mail/lib/mail/elements/address_list.rb +74 -0
  28. data/vendor/mail/lib/mail/elements/content_disposition_element.rb +30 -0
  29. data/vendor/mail/lib/mail/elements/content_location_element.rb +25 -0
  30. data/vendor/mail/lib/mail/elements/content_transfer_encoding_element.rb +24 -0
  31. data/vendor/mail/lib/mail/elements/content_type_element.rb +35 -0
  32. data/vendor/mail/lib/mail/elements/date_time_element.rb +26 -0
  33. data/vendor/mail/lib/mail/elements/envelope_from_element.rb +34 -0
  34. data/vendor/mail/lib/mail/elements/message_ids_element.rb +29 -0
  35. data/vendor/mail/lib/mail/elements/mime_version_element.rb +26 -0
  36. data/vendor/mail/lib/mail/elements/phrase_list.rb +21 -0
  37. data/vendor/mail/lib/mail/elements/received_element.rb +30 -0
  38. data/vendor/mail/lib/mail/encodings.rb +258 -0
  39. data/vendor/mail/lib/mail/encodings/7bit.rb +31 -0
  40. data/vendor/mail/lib/mail/encodings/8bit.rb +31 -0
  41. data/vendor/mail/lib/mail/encodings/base64.rb +33 -0
  42. data/vendor/mail/lib/mail/encodings/binary.rb +31 -0
  43. data/vendor/mail/lib/mail/encodings/quoted_printable.rb +38 -0
  44. data/vendor/mail/lib/mail/encodings/transfer_encoding.rb +58 -0
  45. data/vendor/mail/lib/mail/envelope.rb +35 -0
  46. data/vendor/mail/lib/mail/field.rb +223 -0
  47. data/vendor/mail/lib/mail/field_list.rb +33 -0
  48. data/vendor/mail/lib/mail/fields.rb +35 -0
  49. data/vendor/mail/lib/mail/fields/bcc_field.rb +56 -0
  50. data/vendor/mail/lib/mail/fields/cc_field.rb +55 -0
  51. data/vendor/mail/lib/mail/fields/comments_field.rb +41 -0
  52. data/vendor/mail/lib/mail/fields/common/address_container.rb +16 -0
  53. data/vendor/mail/lib/mail/fields/common/common_address.rb +125 -0
  54. data/vendor/mail/lib/mail/fields/common/common_date.rb +42 -0
  55. data/vendor/mail/lib/mail/fields/common/common_field.rb +50 -0
  56. data/vendor/mail/lib/mail/fields/common/common_message_id.rb +43 -0
  57. data/vendor/mail/lib/mail/fields/common/parameter_hash.rb +52 -0
  58. data/vendor/mail/lib/mail/fields/content_description_field.rb +19 -0
  59. data/vendor/mail/lib/mail/fields/content_disposition_field.rb +69 -0
  60. data/vendor/mail/lib/mail/fields/content_id_field.rb +63 -0
  61. data/vendor/mail/lib/mail/fields/content_location_field.rb +42 -0
  62. data/vendor/mail/lib/mail/fields/content_transfer_encoding_field.rb +50 -0
  63. data/vendor/mail/lib/mail/fields/content_type_field.rb +185 -0
  64. data/vendor/mail/lib/mail/fields/date_field.rb +55 -0
  65. data/vendor/mail/lib/mail/fields/from_field.rb +55 -0
  66. data/vendor/mail/lib/mail/fields/in_reply_to_field.rb +55 -0
  67. data/vendor/mail/lib/mail/fields/keywords_field.rb +44 -0
  68. data/vendor/mail/lib/mail/fields/message_id_field.rb +83 -0
  69. data/vendor/mail/lib/mail/fields/mime_version_field.rb +53 -0
  70. data/vendor/mail/lib/mail/fields/optional_field.rb +13 -0
  71. data/vendor/mail/lib/mail/fields/received_field.rb +67 -0
  72. data/vendor/mail/lib/mail/fields/references_field.rb +55 -0
  73. data/vendor/mail/lib/mail/fields/reply_to_field.rb +55 -0
  74. data/vendor/mail/lib/mail/fields/resent_bcc_field.rb +55 -0
  75. data/vendor/mail/lib/mail/fields/resent_cc_field.rb +55 -0
  76. data/vendor/mail/lib/mail/fields/resent_date_field.rb +35 -0
  77. data/vendor/mail/lib/mail/fields/resent_from_field.rb +55 -0
  78. data/vendor/mail/lib/mail/fields/resent_message_id_field.rb +34 -0
  79. data/vendor/mail/lib/mail/fields/resent_sender_field.rb +62 -0
  80. data/vendor/mail/lib/mail/fields/resent_to_field.rb +55 -0
  81. data/vendor/mail/lib/mail/fields/return_path_field.rb +64 -0
  82. data/vendor/mail/lib/mail/fields/sender_field.rb +67 -0
  83. data/vendor/mail/lib/mail/fields/structured_field.rb +51 -0
  84. data/vendor/mail/lib/mail/fields/subject_field.rb +16 -0
  85. data/vendor/mail/lib/mail/fields/to_field.rb +55 -0
  86. data/vendor/mail/lib/mail/fields/unstructured_field.rb +166 -0
  87. data/vendor/mail/lib/mail/header.rb +262 -0
  88. data/vendor/mail/lib/mail/mail.rb +234 -0
  89. data/vendor/mail/lib/mail/message.rb +1867 -0
  90. data/vendor/mail/lib/mail/network.rb +9 -0
  91. data/vendor/mail/lib/mail/network/delivery_methods/file_delivery.rb +40 -0
  92. data/vendor/mail/lib/mail/network/delivery_methods/sendmail.rb +62 -0
  93. data/vendor/mail/lib/mail/network/delivery_methods/smtp.rb +110 -0
  94. data/vendor/mail/lib/mail/network/delivery_methods/test_mailer.rb +40 -0
  95. data/vendor/mail/lib/mail/network/retriever_methods/imap.rb +18 -0
  96. data/vendor/mail/lib/mail/network/retriever_methods/pop3.rb +149 -0
  97. data/vendor/mail/lib/mail/parsers/address_lists.rb +64 -0
  98. data/vendor/mail/lib/mail/parsers/address_lists.treetop +19 -0
  99. data/vendor/mail/lib/mail/parsers/content_disposition.rb +387 -0
  100. data/vendor/mail/lib/mail/parsers/content_disposition.treetop +46 -0
  101. data/vendor/mail/lib/mail/parsers/content_location.rb +139 -0
  102. data/vendor/mail/lib/mail/parsers/content_location.treetop +20 -0
  103. data/vendor/mail/lib/mail/parsers/content_transfer_encoding.rb +162 -0
  104. data/vendor/mail/lib/mail/parsers/content_transfer_encoding.treetop +20 -0
  105. data/vendor/mail/lib/mail/parsers/content_type.rb +539 -0
  106. data/vendor/mail/lib/mail/parsers/content_type.treetop +58 -0
  107. data/vendor/mail/lib/mail/parsers/date_time.rb +114 -0
  108. data/vendor/mail/lib/mail/parsers/date_time.treetop +11 -0
  109. data/vendor/mail/lib/mail/parsers/envelope_from.rb +194 -0
  110. data/vendor/mail/lib/mail/parsers/envelope_from.treetop +32 -0
  111. data/vendor/mail/lib/mail/parsers/message_ids.rb +45 -0
  112. data/vendor/mail/lib/mail/parsers/message_ids.treetop +15 -0
  113. data/vendor/mail/lib/mail/parsers/mime_version.rb +144 -0
  114. data/vendor/mail/lib/mail/parsers/mime_version.treetop +19 -0
  115. data/vendor/mail/lib/mail/parsers/phrase_lists.rb +45 -0
  116. data/vendor/mail/lib/mail/parsers/phrase_lists.treetop +15 -0
  117. data/vendor/mail/lib/mail/parsers/received.rb +71 -0
  118. data/vendor/mail/lib/mail/parsers/received.treetop +11 -0
  119. data/vendor/mail/lib/mail/parsers/rfc2045.rb +464 -0
  120. data/vendor/mail/lib/mail/parsers/rfc2045.treetop +36 -0
  121. data/vendor/mail/lib/mail/parsers/rfc2822.rb +5318 -0
  122. data/vendor/mail/lib/mail/parsers/rfc2822.treetop +410 -0
  123. data/vendor/mail/lib/mail/parsers/rfc2822_obsolete.rb +3757 -0
  124. data/vendor/mail/lib/mail/parsers/rfc2822_obsolete.treetop +241 -0
  125. data/vendor/mail/lib/mail/part.rb +102 -0
  126. data/vendor/mail/lib/mail/parts_list.rb +34 -0
  127. data/vendor/mail/lib/mail/patterns.rb +30 -0
  128. data/vendor/mail/lib/mail/utilities.rb +181 -0
  129. data/vendor/mail/lib/mail/version.rb +10 -0
  130. data/vendor/mail/lib/mail/version_specific/ruby_1_8.rb +97 -0
  131. data/vendor/mail/lib/mail/version_specific/ruby_1_9.rb +87 -0
  132. data/vendor/mail/lib/tasks/corpus.rake +125 -0
  133. data/vendor/mail/lib/tasks/treetop.rake +10 -0
  134. data/vendor/mail/mail.gemspec +20 -0
  135. data/vendor/mail/reference/US ASCII Table.txt +130 -0
  136. data/vendor/mail/reference/rfc1035 Domain Implementation and Specification.txt +3083 -0
  137. data/vendor/mail/reference/rfc1049 Content-Type Header Field for Internet Messages.txt +451 -0
  138. data/vendor/mail/reference/rfc1344 Implications of MIME for Internet Mail Gateways.txt +586 -0
  139. data/vendor/mail/reference/rfc1345 Character Mnemonics & Character Sets.txt +5761 -0
  140. data/vendor/mail/reference/rfc1524 A User Agent Configuration Mechanism For Multimedia Mail Format Information.txt +675 -0
  141. data/vendor/mail/reference/rfc1652 SMTP Service Extension for 8bit-MIMEtransport.txt +339 -0
  142. data/vendor/mail/reference/rfc1892 Multipart Report .txt +227 -0
  143. data/vendor/mail/reference/rfc1893 Mail System Status Codes.txt +843 -0
  144. data/vendor/mail/reference/rfc2045 Multipurpose Internet Mail Extensions (1).txt +1739 -0
  145. data/vendor/mail/reference/rfc2046 Multipurpose Internet Mail Extensions (2).txt +2467 -0
  146. data/vendor/mail/reference/rfc2047 Multipurpose Internet Mail Extensions (3).txt +843 -0
  147. data/vendor/mail/reference/rfc2048 Multipurpose Internet Mail Extensions (4).txt +1180 -0
  148. data/vendor/mail/reference/rfc2049 Multipurpose Internet Mail Extensions (5).txt +1347 -0
  149. data/vendor/mail/reference/rfc2111 Content-ID and Message-ID URLs.txt +283 -0
  150. data/vendor/mail/reference/rfc2183 Content-Disposition Header Field.txt +675 -0
  151. data/vendor/mail/reference/rfc2231 MIME Parameter Value and Encoded Word Extensions.txt +563 -0
  152. data/vendor/mail/reference/rfc2387 MIME Multipart-Related Content-type.txt +563 -0
  153. data/vendor/mail/reference/rfc2821 Simple Mail Transfer Protocol.txt +3711 -0
  154. data/vendor/mail/reference/rfc2822 Internet Message Format.txt +2859 -0
  155. data/vendor/mail/reference/rfc3462 Reporting of Mail System Administrative Messages.txt +396 -0
  156. data/vendor/mail/reference/rfc3696 Checking and Transformation of Names.txt +898 -0
  157. data/vendor/mail/reference/rfc4155 The application-mbox Media Type.txt +502 -0
  158. data/vendor/mail/reference/rfc4234 Augmented BNF for Syntax Specifications: ABNF.txt +899 -0
  159. data/vendor/mail/reference/rfc822 Standard for the Format of ARPA Internet Text Messages.txt +2900 -0
  160. data/vendor/mail/spec/environment.rb +15 -0
  161. data/vendor/mail/spec/features/making_a_new_message.feature +14 -0
  162. data/vendor/mail/spec/features/steps/env.rb +6 -0
  163. data/vendor/mail/spec/features/steps/making_a_new_message_steps.rb +11 -0
  164. data/vendor/mail/spec/fixtures/attachments/basic_email.eml +31 -0
  165. data/vendor/mail/spec/fixtures/attachments/test.gif +0 -0
  166. data/vendor/mail/spec/fixtures/attachments/test.jpg +0 -0
  167. data/vendor/mail/spec/fixtures/attachments/test.pdf +0 -0
  168. data/vendor/mail/spec/fixtures/attachments/test.png +0 -0
  169. data/vendor/mail/spec/fixtures/attachments/test.tiff +0 -0
  170. data/vendor/mail/spec/fixtures/attachments/test.zip +0 -0
  171. data/vendor/mail/spec/fixtures/attachments//343/201/246/343/201/231/343/201/250.txt +2 -0
  172. data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_content_disposition.eml +29 -0
  173. data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_content_location.eml +32 -0
  174. data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_message_rfc822.eml +92 -0
  175. data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_only_email.eml +17 -0
  176. data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_pdf.eml +70 -0
  177. data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_with_encoded_name.eml +47 -0
  178. data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_with_quoted_filename.eml +60 -0
  179. data/vendor/mail/spec/fixtures/emails/error_emails/cant_parse_from.eml +33 -0
  180. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_7-bit.eml +231 -0
  181. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_empty.eml +33 -0
  182. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_plain.eml +148 -0
  183. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_qp_with_space.eml +53 -0
  184. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_spam.eml +44 -0
  185. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_text-html.eml +50 -0
  186. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_with_8bits.eml +770 -0
  187. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_with_semi_colon.eml +269 -0
  188. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_x_uuencode.eml +79 -0
  189. data/vendor/mail/spec/fixtures/emails/error_emails/empty_group_lists.eml +162 -0
  190. data/vendor/mail/spec/fixtures/emails/error_emails/header_fields_with_empty_values.eml +33 -0
  191. data/vendor/mail/spec/fixtures/emails/error_emails/missing_body.eml +16 -0
  192. data/vendor/mail/spec/fixtures/emails/error_emails/missing_content_disposition.eml +43 -0
  193. data/vendor/mail/spec/fixtures/emails/error_emails/multiple_content_types.eml +25 -0
  194. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email11.eml +34 -0
  195. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email12.eml +32 -0
  196. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email2.eml +114 -0
  197. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email4.eml +59 -0
  198. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email7.eml +66 -0
  199. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_encoded_stack_level_too_deep.eml +53 -0
  200. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_illegal_boundary.eml +58 -0
  201. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_mimepart_without_content_type.eml +94 -0
  202. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_multipart_mixed_quoted_boundary.eml +50 -0
  203. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_nested_attachment.eml +100 -0
  204. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_quoted_illegal_boundary.eml +58 -0
  205. data/vendor/mail/spec/fixtures/emails/mime_emails/sig_only_email.eml +29 -0
  206. data/vendor/mail/spec/fixtures/emails/mime_emails/two_from_in_message.eml +42 -0
  207. data/vendor/mail/spec/fixtures/emails/multi_charset/japanese.eml +9 -0
  208. data/vendor/mail/spec/fixtures/emails/multi_charset/japanese_attachment.eml +27 -0
  209. data/vendor/mail/spec/fixtures/emails/multi_charset/japanese_attachment_long_name.eml +44 -0
  210. data/vendor/mail/spec/fixtures/emails/multipart_report_emails/multi_address_bounce1.eml +179 -0
  211. data/vendor/mail/spec/fixtures/emails/multipart_report_emails/multi_address_bounce2.eml +179 -0
  212. data/vendor/mail/spec/fixtures/emails/multipart_report_emails/report_422.eml +98 -0
  213. data/vendor/mail/spec/fixtures/emails/multipart_report_emails/report_530.eml +97 -0
  214. data/vendor/mail/spec/fixtures/emails/plain_emails/basic_email.eml +31 -0
  215. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email.eml +14 -0
  216. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email10.eml +20 -0
  217. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email5.eml +19 -0
  218. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email6.eml +20 -0
  219. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email8.eml +47 -0
  220. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_bad_time.eml +62 -0
  221. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_double_at_in_header.eml +14 -0
  222. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_incorrect_header.eml +28 -0
  223. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_multiple_from.eml +30 -0
  224. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_quoted_with_0d0a.eml +14 -0
  225. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_reply.eml +32 -0
  226. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_simple.eml +11 -0
  227. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_string_in_date_field.eml +17 -0
  228. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_trailing_dot.eml +21 -0
  229. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_with_bad_date.eml +48 -0
  230. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_with_partially_quoted_subject.eml +14 -0
  231. data/vendor/mail/spec/fixtures/emails/rfc2822/example01.eml +8 -0
  232. data/vendor/mail/spec/fixtures/emails/rfc2822/example02.eml +9 -0
  233. data/vendor/mail/spec/fixtures/emails/rfc2822/example03.eml +7 -0
  234. data/vendor/mail/spec/fixtures/emails/rfc2822/example04.eml +7 -0
  235. data/vendor/mail/spec/fixtures/emails/rfc2822/example05.eml +8 -0
  236. data/vendor/mail/spec/fixtures/emails/rfc2822/example06.eml +10 -0
  237. data/vendor/mail/spec/fixtures/emails/rfc2822/example07.eml +9 -0
  238. data/vendor/mail/spec/fixtures/emails/rfc2822/example08.eml +12 -0
  239. data/vendor/mail/spec/fixtures/emails/rfc2822/example09.eml +15 -0
  240. data/vendor/mail/spec/fixtures/emails/rfc2822/example10.eml +15 -0
  241. data/vendor/mail/spec/fixtures/emails/rfc2822/example11.eml +6 -0
  242. data/vendor/mail/spec/fixtures/emails/rfc2822/example12.eml +8 -0
  243. data/vendor/mail/spec/fixtures/emails/rfc2822/example13.eml +10 -0
  244. data/vendor/mail/spec/fixtures/emails/sample_output_multipart +0 -0
  245. data/vendor/mail/spec/mail/attachments_list_spec.rb +214 -0
  246. data/vendor/mail/spec/mail/body_spec.rb +385 -0
  247. data/vendor/mail/spec/mail/configuration_spec.rb +19 -0
  248. data/vendor/mail/spec/mail/core_extensions/string_spec.rb +62 -0
  249. data/vendor/mail/spec/mail/core_extensions_spec.rb +99 -0
  250. data/vendor/mail/spec/mail/elements/address_list_spec.rb +109 -0
  251. data/vendor/mail/spec/mail/elements/address_spec.rb +609 -0
  252. data/vendor/mail/spec/mail/elements/date_time_element_spec.rb +20 -0
  253. data/vendor/mail/spec/mail/elements/envelope_from_element_spec.rb +31 -0
  254. data/vendor/mail/spec/mail/elements/message_ids_element_spec.rb +43 -0
  255. data/vendor/mail/spec/mail/elements/phrase_list_spec.rb +22 -0
  256. data/vendor/mail/spec/mail/elements/received_element_spec.rb +34 -0
  257. data/vendor/mail/spec/mail/encoding_spec.rb +189 -0
  258. data/vendor/mail/spec/mail/encodings/base64_spec.rb +25 -0
  259. data/vendor/mail/spec/mail/encodings/quoted_printable_spec.rb +25 -0
  260. data/vendor/mail/spec/mail/encodings_spec.rb +664 -0
  261. data/vendor/mail/spec/mail/example_emails_spec.rb +303 -0
  262. data/vendor/mail/spec/mail/field_list_spec.rb +33 -0
  263. data/vendor/mail/spec/mail/field_spec.rb +198 -0
  264. data/vendor/mail/spec/mail/fields/bcc_field_spec.rb +89 -0
  265. data/vendor/mail/spec/mail/fields/cc_field_spec.rb +79 -0
  266. data/vendor/mail/spec/mail/fields/comments_field_spec.rb +25 -0
  267. data/vendor/mail/spec/mail/fields/common/address_container_spec.rb +18 -0
  268. data/vendor/mail/spec/mail/fields/common/common_address_spec.rb +132 -0
  269. data/vendor/mail/spec/mail/fields/common/common_date_spec.rb +25 -0
  270. data/vendor/mail/spec/mail/fields/common/common_field_spec.rb +69 -0
  271. data/vendor/mail/spec/mail/fields/common/common_message_id_spec.rb +30 -0
  272. data/vendor/mail/spec/mail/fields/common/parameter_hash_spec.rb +56 -0
  273. data/vendor/mail/spec/mail/fields/content_description_field_spec.rb +39 -0
  274. data/vendor/mail/spec/mail/fields/content_disposition_field_spec.rb +55 -0
  275. data/vendor/mail/spec/mail/fields/content_id_field_spec.rb +117 -0
  276. data/vendor/mail/spec/mail/fields/content_location_field_spec.rb +46 -0
  277. data/vendor/mail/spec/mail/fields/content_transfer_encoding_field_spec.rb +113 -0
  278. data/vendor/mail/spec/mail/fields/content_type_field_spec.rb +678 -0
  279. data/vendor/mail/spec/mail/fields/date_field_spec.rb +73 -0
  280. data/vendor/mail/spec/mail/fields/envelope_spec.rb +48 -0
  281. data/vendor/mail/spec/mail/fields/from_field_spec.rb +89 -0
  282. data/vendor/mail/spec/mail/fields/in_reply_to_field_spec.rb +62 -0
  283. data/vendor/mail/spec/mail/fields/keywords_field_spec.rb +66 -0
  284. data/vendor/mail/spec/mail/fields/message_id_field_spec.rb +147 -0
  285. data/vendor/mail/spec/mail/fields/mime_version_field_spec.rb +166 -0
  286. data/vendor/mail/spec/mail/fields/received_field_spec.rb +44 -0
  287. data/vendor/mail/spec/mail/fields/references_field_spec.rb +35 -0
  288. data/vendor/mail/spec/mail/fields/reply_to_field_spec.rb +67 -0
  289. data/vendor/mail/spec/mail/fields/resent_bcc_field_spec.rb +66 -0
  290. data/vendor/mail/spec/mail/fields/resent_cc_field_spec.rb +66 -0
  291. data/vendor/mail/spec/mail/fields/resent_date_field_spec.rb +39 -0
  292. data/vendor/mail/spec/mail/fields/resent_from_field_spec.rb +66 -0
  293. data/vendor/mail/spec/mail/fields/resent_message_id_field_spec.rb +24 -0
  294. data/vendor/mail/spec/mail/fields/resent_sender_field_spec.rb +58 -0
  295. data/vendor/mail/spec/mail/fields/resent_to_field_spec.rb +66 -0
  296. data/vendor/mail/spec/mail/fields/return_path_field_spec.rb +52 -0
  297. data/vendor/mail/spec/mail/fields/sender_field_spec.rb +58 -0
  298. data/vendor/mail/spec/mail/fields/structured_field_spec.rb +72 -0
  299. data/vendor/mail/spec/mail/fields/to_field_spec.rb +92 -0
  300. data/vendor/mail/spec/mail/fields/unstructured_field_spec.rb +134 -0
  301. data/vendor/mail/spec/mail/header_spec.rb +578 -0
  302. data/vendor/mail/spec/mail/mail_spec.rb +34 -0
  303. data/vendor/mail/spec/mail/message_spec.rb +1409 -0
  304. data/vendor/mail/spec/mail/mime_messages_spec.rb +435 -0
  305. data/vendor/mail/spec/mail/multipart_report_spec.rb +112 -0
  306. data/vendor/mail/spec/mail/network/delivery_methods/file_delivery_spec.rb +79 -0
  307. data/vendor/mail/spec/mail/network/delivery_methods/sendmail_spec.rb +125 -0
  308. data/vendor/mail/spec/mail/network/delivery_methods/smtp_spec.rb +133 -0
  309. data/vendor/mail/spec/mail/network/delivery_methods/test_mailer_spec.rb +57 -0
  310. data/vendor/mail/spec/mail/network/retriever_methods/pop3_spec.rb +180 -0
  311. data/vendor/mail/spec/mail/network_spec.rb +359 -0
  312. data/vendor/mail/spec/mail/parsers/address_lists_parser_spec.rb +15 -0
  313. data/vendor/mail/spec/mail/parsers/content_transfer_encoding_parser_spec.rb +72 -0
  314. data/vendor/mail/spec/mail/part_spec.rb +129 -0
  315. data/vendor/mail/spec/mail/parts_list_spec.rb +12 -0
  316. data/vendor/mail/spec/mail/round_tripping_spec.rb +44 -0
  317. data/vendor/mail/spec/mail/utilities_spec.rb +327 -0
  318. data/vendor/mail/spec/mail/version_specific/escape_paren_1_8_spec.rb +32 -0
  319. data/vendor/mail/spec/matchers/break_down_to.rb +35 -0
  320. data/vendor/mail/spec/spec_helper.rb +163 -0
  321. metadata +442 -0
@@ -0,0 +1,3 @@
1
+ treetop: we need to include this in the gem spec
2
+ tlsmail: if ruby < 1.8.6... we could make it optional, or embed it in Mail
3
+ mime/types: I think we embed a simplified version, or help maintain it, it is old (2006)
@@ -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.