mail 2.4.4 → 2.6.3
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.
- checksums.yaml +7 -0
- data/CHANGELOG.rdoc +156 -0
- data/CONTRIBUTING.md +21 -6
- data/Dependencies.txt +0 -1
- data/Gemfile +10 -21
- data/MIT-LICENSE +20 -0
- data/README.md +52 -32
- data/Rakefile +11 -22
- data/lib/mail/attachments_list.rb +2 -2
- data/lib/mail/body.rb +33 -9
- data/lib/mail/check_delivery_params.rb +20 -0
- data/lib/mail/configuration.rb +1 -1
- data/lib/mail/{patterns.rb → constants.rb} +26 -6
- data/lib/mail/core_extensions/nil.rb +4 -2
- data/lib/mail/core_extensions/object.rb +8 -8
- data/lib/mail/core_extensions/smtp.rb +12 -13
- data/lib/mail/core_extensions/string.rb +19 -6
- data/lib/mail/elements/address.rb +82 -141
- data/lib/mail/elements/address_list.rb +9 -42
- data/lib/mail/elements/content_disposition_element.rb +3 -7
- data/lib/mail/elements/content_location_element.rb +2 -6
- data/lib/mail/elements/content_transfer_encoding_element.rb +3 -10
- data/lib/mail/elements/content_type_element.rb +4 -8
- data/lib/mail/elements/date_time_element.rb +3 -7
- data/lib/mail/elements/envelope_from_element.rb +18 -13
- data/lib/mail/elements/message_ids_element.rb +1 -6
- data/lib/mail/elements/mime_version_element.rb +3 -7
- data/lib/mail/elements/phrase_list.rb +2 -7
- data/lib/mail/elements/received_element.rb +3 -7
- data/lib/mail/elements.rb +12 -12
- data/lib/mail/encodings/quoted_printable.rb +4 -3
- data/lib/mail/encodings/unix_to_unix.rb +17 -0
- data/lib/mail/encodings.rb +53 -38
- data/lib/mail/envelope.rb +0 -5
- data/lib/mail/field.rb +131 -118
- data/lib/mail/field_list.rb +18 -18
- data/lib/mail/fields/bcc_field.rb +2 -2
- data/lib/mail/fields/cc_field.rb +2 -2
- data/lib/mail/fields/comments_field.rb +1 -1
- data/lib/mail/fields/common/common_address.rb +32 -22
- data/lib/mail/fields/common/common_date.rb +0 -7
- data/lib/mail/fields/common/common_field.rb +10 -3
- data/lib/mail/fields/common/common_message_id.rb +9 -5
- data/lib/mail/fields/common/parameter_hash.rb +3 -3
- data/lib/mail/fields/content_disposition_field.rb +1 -0
- data/lib/mail/fields/content_id_field.rb +1 -2
- data/lib/mail/fields/content_transfer_encoding_field.rb +2 -8
- data/lib/mail/fields/content_type_field.rb +5 -2
- data/lib/mail/fields/date_field.rb +14 -14
- data/lib/mail/fields/from_field.rb +2 -2
- data/lib/mail/fields/in_reply_to_field.rb +2 -1
- data/lib/mail/fields/keywords_field.rb +1 -1
- data/lib/mail/fields/message_id_field.rb +2 -3
- data/lib/mail/fields/references_field.rb +2 -1
- data/lib/mail/fields/reply_to_field.rb +2 -2
- data/lib/mail/fields/resent_bcc_field.rb +2 -2
- data/lib/mail/fields/resent_cc_field.rb +2 -2
- data/lib/mail/fields/resent_from_field.rb +2 -2
- data/lib/mail/fields/resent_sender_field.rb +3 -3
- data/lib/mail/fields/resent_to_field.rb +2 -2
- data/lib/mail/fields/sender_field.rb +8 -8
- data/lib/mail/fields/to_field.rb +2 -2
- data/lib/mail/fields/unstructured_field.rb +44 -31
- data/lib/mail/fields.rb +32 -32
- data/lib/mail/header.rb +47 -37
- data/lib/mail/mail.rb +15 -1
- data/lib/mail/matchers/has_sent_mail.rb +36 -3
- data/lib/mail/message.rb +164 -57
- data/lib/mail/multibyte/chars.rb +4 -4
- data/lib/mail/multibyte/unicode.rb +9 -1
- data/lib/mail/network/delivery_methods/exim.rb +2 -3
- data/lib/mail/network/delivery_methods/file_delivery.rb +5 -0
- data/lib/mail/network/delivery_methods/sendmail.rb +35 -8
- data/lib/mail/network/delivery_methods/smtp.rb +34 -45
- data/lib/mail/network/delivery_methods/smtp_connection.rb +9 -22
- data/lib/mail/network/delivery_methods/test_mailer.rb +6 -2
- data/lib/mail/network/retriever_methods/imap.rb +32 -19
- data/lib/mail/network/retriever_methods/pop3.rb +2 -2
- data/lib/mail/network/retriever_methods/test_retriever.rb +11 -15
- data/lib/mail/network.rb +9 -9
- data/lib/mail/parsers/address_lists_parser.rb +132 -0
- data/lib/mail/parsers/content_disposition_parser.rb +67 -0
- data/lib/mail/parsers/content_location_parser.rb +35 -0
- data/lib/mail/parsers/content_transfer_encoding_parser.rb +33 -0
- data/lib/mail/parsers/content_type_parser.rb +66 -0
- data/lib/mail/parsers/date_time_parser.rb +36 -0
- data/lib/mail/parsers/envelope_from_parser.rb +45 -0
- data/lib/mail/parsers/message_ids_parser.rb +39 -0
- data/lib/mail/parsers/mime_version_parser.rb +41 -0
- data/lib/mail/parsers/phrase_lists_parser.rb +33 -0
- data/lib/mail/parsers/ragel/common.rl +185 -0
- data/lib/mail/parsers/ragel/date_time.rl +30 -0
- data/lib/mail/parsers/ragel/parser_info.rb +61 -0
- data/lib/mail/parsers/ragel/ruby/machines/address_lists_machine.rb +14864 -0
- data/lib/mail/parsers/ragel/ruby/machines/address_lists_machine.rb.rl +37 -0
- data/lib/mail/parsers/ragel/ruby/machines/content_disposition_machine.rb +751 -0
- data/lib/mail/parsers/ragel/ruby/machines/content_disposition_machine.rb.rl +37 -0
- data/lib/mail/parsers/ragel/ruby/machines/content_location_machine.rb +614 -0
- data/lib/mail/parsers/ragel/ruby/machines/content_location_machine.rb.rl +37 -0
- data/lib/mail/parsers/ragel/ruby/machines/content_transfer_encoding_machine.rb +447 -0
- data/lib/mail/parsers/ragel/ruby/machines/content_transfer_encoding_machine.rb.rl +37 -0
- data/lib/mail/parsers/ragel/ruby/machines/content_type_machine.rb +825 -0
- data/lib/mail/parsers/ragel/ruby/machines/content_type_machine.rb.rl +37 -0
- data/lib/mail/parsers/ragel/ruby/machines/date_time_machine.rb +817 -0
- data/lib/mail/parsers/ragel/ruby/machines/date_time_machine.rb.rl +37 -0
- data/lib/mail/parsers/ragel/ruby/machines/envelope_from_machine.rb +2149 -0
- data/lib/mail/parsers/ragel/ruby/machines/envelope_from_machine.rb.rl +37 -0
- data/lib/mail/parsers/ragel/ruby/machines/message_ids_machine.rb +1570 -0
- data/lib/mail/parsers/ragel/ruby/machines/message_ids_machine.rb.rl +37 -0
- data/lib/mail/parsers/ragel/ruby/machines/mime_version_machine.rb +440 -0
- data/lib/mail/parsers/ragel/ruby/machines/mime_version_machine.rb.rl +37 -0
- data/lib/mail/parsers/ragel/ruby/machines/phrase_lists_machine.rb +564 -0
- data/lib/mail/parsers/ragel/ruby/machines/phrase_lists_machine.rb.rl +37 -0
- data/lib/mail/parsers/ragel/ruby/machines/rb_actions.rl +51 -0
- data/lib/mail/parsers/ragel/ruby/machines/received_machine.rb +5144 -0
- data/lib/mail/parsers/ragel/ruby/machines/received_machine.rb.rl +37 -0
- data/lib/mail/parsers/ragel/ruby/parser.rb.rl.erb +37 -0
- data/lib/mail/parsers/ragel/ruby.rb +40 -0
- data/lib/mail/parsers/ragel.rb +17 -0
- data/lib/mail/parsers/received_parser.rb +47 -0
- data/lib/mail/parsers.rb +26 -0
- data/lib/mail/part.rb +6 -2
- data/lib/mail/parts_list.rb +5 -3
- data/lib/mail/utilities.rb +70 -60
- data/lib/mail/values/unicode_tables.dat +0 -0
- data/lib/mail/version.rb +7 -15
- data/lib/mail/version_specific/ruby_1_8.rb +25 -4
- data/lib/mail/version_specific/ruby_1_9.rb +110 -30
- data/lib/mail.rb +20 -19
- metadata +129 -73
- data/Gemfile.lock +0 -36
- data/lib/VERSION +0 -4
- data/lib/mail/core_extensions/shell_escape.rb +0 -56
- data/lib/mail/parsers/address_lists.rb +0 -64
- data/lib/mail/parsers/address_lists.treetop +0 -19
- data/lib/mail/parsers/content_disposition.rb +0 -535
- data/lib/mail/parsers/content_disposition.treetop +0 -46
- data/lib/mail/parsers/content_location.rb +0 -139
- data/lib/mail/parsers/content_location.treetop +0 -20
- data/lib/mail/parsers/content_transfer_encoding.rb +0 -162
- data/lib/mail/parsers/content_transfer_encoding.treetop +0 -20
- data/lib/mail/parsers/content_type.rb +0 -967
- data/lib/mail/parsers/content_type.treetop +0 -68
- data/lib/mail/parsers/date_time.rb +0 -114
- data/lib/mail/parsers/date_time.treetop +0 -11
- data/lib/mail/parsers/envelope_from.rb +0 -194
- data/lib/mail/parsers/envelope_from.treetop +0 -32
- data/lib/mail/parsers/message_ids.rb +0 -45
- data/lib/mail/parsers/message_ids.treetop +0 -15
- data/lib/mail/parsers/mime_version.rb +0 -144
- data/lib/mail/parsers/mime_version.treetop +0 -19
- data/lib/mail/parsers/phrase_lists.rb +0 -45
- data/lib/mail/parsers/phrase_lists.treetop +0 -15
- data/lib/mail/parsers/received.rb +0 -71
- data/lib/mail/parsers/received.treetop +0 -11
- data/lib/mail/parsers/rfc2045.rb +0 -464
- data/lib/mail/parsers/rfc2045.treetop +0 -36
- data/lib/mail/parsers/rfc2822.rb +0 -5341
- data/lib/mail/parsers/rfc2822.treetop +0 -410
- data/lib/mail/parsers/rfc2822_obsolete.rb +0 -3768
- data/lib/mail/parsers/rfc2822_obsolete.treetop +0 -241
- data/lib/tasks/corpus.rake +0 -125
- data/lib/tasks/treetop.rake +0 -10
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 3af499471587d4cb917ab992eb4bb45f19b9579e
|
|
4
|
+
data.tar.gz: f05e6aaf887b9a79b9252e7edc2dd74b81f7cb6c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 75bb13148f71ffbbef303ca23f01b0c6c8a14aeea255bd528ba3ac0545c056b75ff3a420dc0578c7f15efd894a3367072496121c8479aa8ddc78e376c115168f
|
|
7
|
+
data.tar.gz: 0f26c569a7c210d3ee57d95cf5011f8ff4941f5c1cd054ef804f018aa829bec44db3fdde7ab2fe1a89056cf81a5e6d618735caaaf9ccf4e8810e4295256f012e
|
data/CHANGELOG.rdoc
CHANGED
|
@@ -1,5 +1,161 @@
|
|
|
1
1
|
== HEAD
|
|
2
2
|
|
|
3
|
+
== Version 2.6.3 - Mon Nov 3 23:53 +1100 2014 Mikel Lindsaar <mikel@reinteractive.net>
|
|
4
|
+
|
|
5
|
+
* #796 support uu encoding (grosser)
|
|
6
|
+
|
|
7
|
+
== Version 2.6.2 (Unreleased) - Wed Oct 22 13:42 -0500 2014 Benjamin Fleischer <github@benjaminfleischer.com>
|
|
8
|
+
|
|
9
|
+
Performance:
|
|
10
|
+
* #681 - fewer hotspot object allocations (srawlins)
|
|
11
|
+
* #815 - autoload parsers for load-time speed and memory usage (grosser)
|
|
12
|
+
|
|
13
|
+
Bugs:
|
|
14
|
+
* #736 - Mail.new copes with non-UTF8 messages marked as UTF8 (jeremy)
|
|
15
|
+
|
|
16
|
+
== Version 2.6.1 - Sun Jun 8 15:34 +1100 2014 Mikel Lindsaar <mikel@reinteractive.net>
|
|
17
|
+
|
|
18
|
+
Features:
|
|
19
|
+
* Silence warnings on loading ragel-generated parsers (bf4)
|
|
20
|
+
|
|
21
|
+
== Version 2.6.0 - Mon Jun 2 22:49 +1100 2014 Mikel Lindsaar <mikel@reinteractive.net>
|
|
22
|
+
|
|
23
|
+
Features:
|
|
24
|
+
* Allow interceptors and observers to be unregistered (zuhao)
|
|
25
|
+
* Added feature to find the mail in uid (taketin)
|
|
26
|
+
* Save settings passed to TestMailer#new (svanderbleek)
|
|
27
|
+
* Allow the setting of envelope from directly (jeremy)
|
|
28
|
+
* Accept other IETF/IANA-registered Content-Types and Content-Transfer-Encodings (jeremy)
|
|
29
|
+
* Alias shift-jis charset to Shift_JIS Ruby encoding (jeremy)
|
|
30
|
+
* Add support for ks_c_5601-1987 charset, aliased to CP949 Ruby encoding (jeremy)
|
|
31
|
+
* Don't allow colons in header names (jeremy)
|
|
32
|
+
* Can assign arrays of Message-IDs to References and In-Reply-To (jeremy)
|
|
33
|
+
* Setting the html_ or text_part sets a default text/html or text/plain content type (jeremy)
|
|
34
|
+
* Setting the html_ or text_part to nil removes it (jeremy)
|
|
35
|
+
* Addresses without a parsable email or display name still format as their raw text (jeremy)
|
|
36
|
+
* Close pull request 504 - Alias GB2312 charset to GB18030 Ruby encoding (bpot)
|
|
37
|
+
* Close pull request 399 - Accept :ca_path and :ca_file options for SMTP delivery (ndbroadbent)
|
|
38
|
+
* Close pull request 389 - Don't add superfluous message headers to MIME parts (djmaze, jeremy)
|
|
39
|
+
|
|
40
|
+
Performance:
|
|
41
|
+
* Migrate to RAGEL based parser, awesome work by (bpot)
|
|
42
|
+
* Performance improvements for people parsing email headers (ConradIrwin)
|
|
43
|
+
* Close pull request 488 - Speed up field construction & comparison (bpot)
|
|
44
|
+
|
|
45
|
+
Bugs:
|
|
46
|
+
* Fix for when content looks like field name (kjg)
|
|
47
|
+
* Don't change original when you change a copy (TylerRick)
|
|
48
|
+
* Don't include separating semicolon in paramter value when sanitizing (bpot)
|
|
49
|
+
* Fix fencepost encoding problem with binhex strings and only one token (drasch)
|
|
50
|
+
* Fix sendmail delivery to addresses with a leading hyphen (lifo, jeremy)
|
|
51
|
+
* Correctly format mbox From headers per RFC4155 (bpot, jeremy)
|
|
52
|
+
* Fix bogus '=' at the end of some quoted-printable messages (jeremy)
|
|
53
|
+
* Shouldn't be fooled into encoding strings on 1.8 by unrelated Encoding constant (emiellohr, jeremy)
|
|
54
|
+
* Header encoding should be US-ASCII, not the default external encoding (jeremy)
|
|
55
|
+
* Address elements should return decoded display names by default (jeremy)
|
|
56
|
+
* Fix up tests that depend on utf-8 external encoding; read fixtures as binary (jeremy)
|
|
57
|
+
* Capture stderr from Sendmail and Exim deliveries (jeremy)
|
|
58
|
+
* RFC2822 quoted_string content may be empty (jeremy)
|
|
59
|
+
* Calling #to_s on a field with a nil value returns an empty string instead of nil (jeremy)
|
|
60
|
+
* The Received header may contain zero name/value pairs, qmail-style (jeremy)
|
|
61
|
+
* Fix that setting an attachment with a :mime_type and :encoding would override the :encoding (jeremy)
|
|
62
|
+
* Fix that declaring an html_part but no text_part would use multipart/alternative anyway (jeremy)
|
|
63
|
+
* Close pull request 508 - Don't add an extra CRLF to MIME parts; split MIME parts on correct CRLF boundaries (Aalanar)
|
|
64
|
+
* Close pull request 506 - Escape backslashes in quoted strings (ConradIrwin)
|
|
65
|
+
* Close pull request 496 - Correctly handle quoted-printable line breaks (jeremy)
|
|
66
|
+
* Close pull request 493 - Repair misencoded quoted-printable line breaks (jeremy)
|
|
67
|
+
* Close pull request 487 - Extract comments from group email addresses (bpot)
|
|
68
|
+
* Close pull request 481 - Correctly quote filename attributes (bpot)
|
|
69
|
+
* Close pull request 480 - Support mixed encodings in a single header body (adamvaughan)
|
|
70
|
+
* Close pull request 471 - Fix Ruby 1.8 build when UTF16/32 default to little-endian (kennyj)
|
|
71
|
+
|
|
72
|
+
Coping with third-party bugs:
|
|
73
|
+
* Parse multipart boundary from Content-Type headers containing extra semicolons (jeremy)
|
|
74
|
+
* Close pull request 389 - Only add Content-ID to inline attachments to appease Outlook (djmaze, jeremy)
|
|
75
|
+
|
|
76
|
+
Housekeeping:
|
|
77
|
+
* Add development gem dependency on rdoc (jeremy)
|
|
78
|
+
* Refresh Bundler dependencies & setup (jeremy)
|
|
79
|
+
* Remove i18n dependency and last vestiges of activesupport dependency in specs (jeremy)
|
|
80
|
+
* Clarify that Sender is a single address, not an address list (jeremy)
|
|
81
|
+
* Add an MIT-LICENSE file to make licensing clear & obvious; update to 2013 (jeremy)
|
|
82
|
+
* Close pull request 501 - Tighten up header/body whitespace splitting (ConradIrwin)
|
|
83
|
+
* Close pull request 499 - Clean up some dead code (ConradIrwin)
|
|
84
|
+
* Close pull request 489, 495 - Docs typos (JackDanger, francois)
|
|
85
|
+
* Close pull request 485 - Be explicit about unsupported address parsing (bpot)
|
|
86
|
+
* Close pull request 484 - Remove #tree specs in preparation for deprecation removal (bpot)
|
|
87
|
+
* Close pull request 482 - Update address field specs to reflect to #initialize API (bpot)
|
|
88
|
+
* Close pull request 475 - Shush warning on Object#blank? redefinition (amatsuda)
|
|
89
|
+
* Close pull request 472 - Clean up UTF8/UTF-8 internals (kennyj)
|
|
90
|
+
|
|
91
|
+
== Version 2.5.3 - Sun Dec 4 15:52:00 +1100 2012 Mikel Lindsaar <mikel@reinteractive.net>
|
|
92
|
+
|
|
93
|
+
* Close pull request 468 - Remove debug output to STDOUT (tadman)
|
|
94
|
+
* Fix up spec warnings
|
|
95
|
+
* Remove un needed require
|
|
96
|
+
* Ensure spec_helper constants only defined once
|
|
97
|
+
* Use stub against time instead of DateTime to avoid double redefinition error
|
|
98
|
+
|
|
99
|
+
== Version 2.5.2 - Sun Nov 18 15:01:00 +1100 2012 Mikel Lindsaar <mikel@reinteractive.net>
|
|
100
|
+
|
|
101
|
+
* Removing double loading of treetop parsers to remove warnings
|
|
102
|
+
* Making parsers auto compile on spec suite and load in production code to avoid error that caused yank of 2.5.0
|
|
103
|
+
* Reapply pull request 443 - CC fields with semicolon are now parsed right (paulwittmann)
|
|
104
|
+
|
|
105
|
+
== Version 2.5.1 - Sun Nov 18 14:01:00 +1100 2012 Mikel Lindsaar <mikel@reinteractive.net>
|
|
106
|
+
|
|
107
|
+
* Yanked 2.5.0
|
|
108
|
+
* Reverted pull request 443 - CC fields with semicolon are now parsed right (paulwittmann)
|
|
109
|
+
|
|
110
|
+
== Version 2.5.0 - Sun Nov 18 12:20:00 +1100 2012 Mikel Lindsaar <mikel@reinteractive.net>
|
|
111
|
+
|
|
112
|
+
Features:
|
|
113
|
+
* Close pull request 406 - Add Mail#eager_autoload! to load all autoloaded files on demand (bpot)
|
|
114
|
+
* Close pull request 461 - Allow string as delivery_method (skyeagle, radar)
|
|
115
|
+
* Close pull request 407 - Do not require Net::IMAP or Net::POP if they're already loaded (bpot)
|
|
116
|
+
* Close pull request 400 - Raise exception if delivery values or from values are missing completely from an email that is getting delivered (dmathieu)
|
|
117
|
+
* Close pull request 397 - Support dots in local part of the addresses (eac)
|
|
118
|
+
* Close pull request 477 - Fixed handling content_type with superfluous spaces (ledermann)
|
|
119
|
+
* Close pull request 451 - Ignore nil in addresses so things do not blow up when e.g. a user had no email (grosser)
|
|
120
|
+
* Close pull request 362 - Enable TLS in Ruby 1.8 (kingargyle)
|
|
121
|
+
* Close pull request 358 - Fix Mail::CommonAddress#value=, Mail::CommonAddress#<< and Mail::Encodings.encode_non_usascii (mrkn)
|
|
122
|
+
* Close pull request 350 - Makes mail Header object ennumerable (ged)
|
|
123
|
+
|
|
124
|
+
Performance:
|
|
125
|
+
* Close pull request 369 - Mail::Header#charset is called pretty often during header parser work (bogdan)
|
|
126
|
+
* Close pull request 368 - Improve existing code by moving some objects to contstant instead of constructing them over and over again. (bogdan)
|
|
127
|
+
* Close pull request 366 - Headers parsing performance optimization (bogdan)
|
|
128
|
+
* Close pull request 365 - Add maximum_amount of parsed headers configuration parameter (bogdan)
|
|
129
|
+
|
|
130
|
+
Bugs:
|
|
131
|
+
* Close pull request 444 - Fix typo in spec (cczona)
|
|
132
|
+
* Close pull request 439 - Fix Ruby 1.9 behaviour to match 1.8.7 behaviour on ignoring invalid or undefined characters (ochko)
|
|
133
|
+
* Close pull request 430 - Unstructured field converts to string before calling encoding on it (brupm mikel)
|
|
134
|
+
* Close pull request 424 - Use String#to_crlf instead of String#gsub (okkez)
|
|
135
|
+
* Close pull request 429 - Fix an obvious bug in exim delivery_method (dskim)
|
|
136
|
+
* Close pull request 425 - Remove Gemfile.lock from generated gem (kbackowski)
|
|
137
|
+
* Close pull request 414 - Fix typo on "ignoring" (derwiki)
|
|
138
|
+
* Close pull request 405 - Fix stack overflow (RegexpError) triggered by large emails with an envelope (bpot)
|
|
139
|
+
* Close pull request 402 - Prevent InReplyTo, Keyword, References or ResentMessageId fields from generating lines longer than 998 chars (pplr)
|
|
140
|
+
* Close pull request 391 - Fixed failed attachment parsing when file name in headers contains spaces and is not wrapped in quotes (danieltreacy)
|
|
141
|
+
* Close pull request 385 - Fix Multibyte::Chars#upcase/downcase (technoweenie)
|
|
142
|
+
* Close pull request 384 - copy dat unicode over from active support (technoweenie)
|
|
143
|
+
* Close pull request 380 - Split strictly on MIME boundary lines (ConradIrwin)
|
|
144
|
+
* Close pull request 277 - Fix specific email decoding failure example (yalab)
|
|
145
|
+
* Close pull request 361 - Support 8bit encoding for ruby 1.9 (bogdan)
|
|
146
|
+
* Close pull request 346 - Fix two bugs of TestRetriever (ermaker)
|
|
147
|
+
* Close pull request 337 - Make the behavior of value_decode the same between Ruby 1.8 and Ruby 1.9. (kennyj)
|
|
148
|
+
* Close pull request 336 - Fix more warning: possibly useless use of == in void context (kennyj)
|
|
149
|
+
* Close pull request 293 - make charset and mime type more resliant to bad header values (kmeehl)
|
|
150
|
+
* Fix failing spec Issue 453 on Ruby 1.9.3
|
|
151
|
+
* Fix mail reading: don't raise invalid byte sequence in UTF-8 when reading non-UTF-8 emails (mreinsch)
|
|
152
|
+
* Close pull request 353 - define NilClass#blank? only if not defined yet (amatsuda)
|
|
153
|
+
* Close pull request 357 - Fixes #349 an inverted condition on imap open read_only (felixroeser)
|
|
154
|
+
* Remove duplicated line feed from regexp
|
|
155
|
+
* Remove unused variable
|
|
156
|
+
* Updated IMAP documentation
|
|
157
|
+
* Tweak publisher
|
|
158
|
+
|
|
3
159
|
== Version 2.4.4 - Wed Mar 14 22:44:00 +1100 2012 Mikel Lindsaar <mikel@reinteractive.net>
|
|
4
160
|
|
|
5
161
|
* Fix security vulnerability allowing command line exploit when using file delivery method
|
data/CONTRIBUTING.md
CHANGED
|
@@ -12,12 +12,14 @@ pull request merged quickly:
|
|
|
12
12
|
5. Add a spec for your change. Only refactoring and documentation changes
|
|
13
13
|
require no new specs. If you are adding functionality or fixing a bug, we need
|
|
14
14
|
a spec!
|
|
15
|
-
6. Test the spec _at_ _least_ against MRI-1.9.
|
|
15
|
+
6. Test the spec _at_ _least_ against MRI-1.9.3 and MRI-1.8.7
|
|
16
16
|
7. Update the README if needed to reflect your change / addition
|
|
17
|
-
8.
|
|
18
|
-
9.
|
|
17
|
+
8. Update the CHANGELOG and give yourself credit
|
|
18
|
+
9. With all specs passing push your changes back to your fork
|
|
19
|
+
10. Send me a pull request.
|
|
20
|
+
- If it needs any changes, please push or force push to the same branch you made the pull request from. GitHub will just update the pull request with your changes.
|
|
19
21
|
|
|
20
|
-
Note, specs that break MRI 1.8.7 will not be accepted.
|
|
22
|
+
Note, specs that break MRI 1.8.7 or 1.9.3 will not be accepted.
|
|
21
23
|
|
|
22
24
|
At this point you're waiting on us. We like to at least comment on, if not
|
|
23
25
|
accept, pull requests within three business days (and, typically, one business
|
|
@@ -28,7 +30,7 @@ taken straight from the Ruby on Rails guide:
|
|
|
28
30
|
|
|
29
31
|
* Tell me you have tested it against more than one version of Ruby, RVM is great for
|
|
30
32
|
this. I test against 7 rubies before I push into master.
|
|
31
|
-
* Use good, idiomatic,
|
|
33
|
+
* Use good, idiomatic, structured and modular code
|
|
32
34
|
* Include tests that fail without your code, and pass with it
|
|
33
35
|
* Update the documentation, the surrounding one, examples elsewhere, guides,
|
|
34
36
|
whatever is affected by your contribution
|
|
@@ -42,4 +44,17 @@ Syntax:
|
|
|
42
44
|
* a = b and not a=b.
|
|
43
45
|
* Follow the conventions you see used in the source already.
|
|
44
46
|
|
|
45
|
-
And in case we didn't emphasize it enough: we love specs!
|
|
47
|
+
And in case we didn't emphasize it enough: we love specs!
|
|
48
|
+
|
|
49
|
+
### Testing against mime-types versions:
|
|
50
|
+
|
|
51
|
+
Use [appraisal](https://github.com/thoughtbot/appraisal) to run against all supported versions of mime-types.
|
|
52
|
+
|
|
53
|
+
1. Run `(bundle check || bundle) && appraisal` so that all the 'appraised' gemfiles are bundled.
|
|
54
|
+
2. Run either `appraisal rake` or `rake appraisal` to run all the tests.
|
|
55
|
+
|
|
56
|
+
To run only one 'appraised' gemfile, run. e.g. `BUNDLE_GEMFILE=gemfiles/mime_types_edge.gemfile (bundle check || bundle) && rake`
|
|
57
|
+
|
|
58
|
+
To change the appraisals, modify the `Appraisals` file, run `appraisal`, commit the generated gemfiles, and modify the .travis.yml matrix.
|
|
59
|
+
|
|
60
|
+
To run on all rubies / gemfiles, just like TravisCI, see [WWTD](https://github.com/grosser/wwtd).
|
data/Dependencies.txt
CHANGED
data/Gemfile
CHANGED
|
@@ -1,26 +1,15 @@
|
|
|
1
|
-
source
|
|
1
|
+
source "https://rubygems.org"
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
gem "tlsmail" if RUBY_VERSION <= '1.8.6'
|
|
5
|
-
gem "mime-types", "~> 1.16"
|
|
6
|
-
gem "treetop", "~> 1.4.10"
|
|
7
|
-
gem "i18n", ">= 0.4.0"
|
|
3
|
+
gemspec
|
|
8
4
|
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
gem "tlsmail", "~> 0.0.1" if RUBY_VERSION <= "1.8.6"
|
|
6
|
+
gem "jruby-openssl", :platforms => :jruby
|
|
7
|
+
|
|
8
|
+
group :development, :test do
|
|
9
|
+
gem "appraisal", "~> 1.0"
|
|
11
10
|
end
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
gem "
|
|
16
|
-
case
|
|
17
|
-
when defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
|
|
18
|
-
# Skip it
|
|
19
|
-
when RUBY_PLATFORM == 'java'
|
|
20
|
-
# Skip it
|
|
21
|
-
when RUBY_VERSION < '1.9'
|
|
22
|
-
gem "ruby-debug"
|
|
23
|
-
else
|
|
24
|
-
# Skip it
|
|
25
|
-
end
|
|
12
|
+
# For gems not required to run tests
|
|
13
|
+
group :local_development, :test do
|
|
14
|
+
gem "ruby-debug", :platforms => :mri_18
|
|
26
15
|
end
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2009-2013 Mikel Lindsaar
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
'Software'), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Mail
|
|
1
|
+
Mail [](https://travis-ci.org/mikel/mail)
|
|
2
2
|
====
|
|
3
3
|
|
|
4
4
|
Introduction
|
|
@@ -15,11 +15,11 @@ Built from my experience with TMail, it is designed to be a pure ruby
|
|
|
15
15
|
implementation that makes generating, sending and parsing emails a no
|
|
16
16
|
brainer.
|
|
17
17
|
|
|
18
|
-
It is also designed
|
|
19
|
-
Ruby 1.9 handles text encodings much more
|
|
20
|
-
these features have been taken full advantage of in this
|
|
21
|
-
Mail to handle a lot more messages more cleanly than TMail.
|
|
22
|
-
Ruby 1.8.x... it's just not as fun to code.
|
|
18
|
+
It is also designed from the ground up to work with the more modern versions
|
|
19
|
+
of Ruby. This is because Ruby > 1.9 handles text encodings much more wonderfully
|
|
20
|
+
than Ruby 1.8.x and so these features have been taken full advantage of in this
|
|
21
|
+
library allowing Mail to handle a lot more messages more cleanly than TMail.
|
|
22
|
+
Mail does run on Ruby 1.8.x... it's just not as fun to code.
|
|
23
23
|
|
|
24
24
|
Finally, Mail has been designed with a very simple object oriented system
|
|
25
25
|
that really opens up the email messages you are parsing, if you know what
|
|
@@ -29,7 +29,7 @@ Donations
|
|
|
29
29
|
-------------
|
|
30
30
|
|
|
31
31
|
Mail has been downloaded millions of times, by people around the world, in fact,
|
|
32
|
-
it represents more than 1% of *all* gems downloaded.
|
|
32
|
+
it represents more than 1% of *all* gems downloaded.
|
|
33
33
|
|
|
34
34
|
It is (like all open source software) a labour of love and something I am doing
|
|
35
35
|
with my own free time. If you would like to say thanks, please feel free to
|
|
@@ -42,14 +42,23 @@ me a nice email :)
|
|
|
42
42
|
Compatibility
|
|
43
43
|
-------------
|
|
44
44
|
|
|
45
|
-
Mail is tested by Travis
|
|
45
|
+
Every Mail commit is tested by Travis on the [following platforms](https://github.com/mikel/mail/blob/master/.travis.yml)
|
|
46
46
|
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* ruby-
|
|
51
|
-
* ruby-1.
|
|
52
|
-
* ruby-
|
|
47
|
+
* ruby-1.8.7 [ i686 ]
|
|
48
|
+
* ruby-1.9.2 [ x86_64 ]
|
|
49
|
+
* ruby-1.9.3 [ x86_64 ]
|
|
50
|
+
* ruby-2.0.0 [ x86_64 ]
|
|
51
|
+
* ruby-2.1.2 [ x86_64 ]
|
|
52
|
+
* ruby-head [ x86_64 ]
|
|
53
|
+
* jruby [ x86_64 ]
|
|
54
|
+
* jruby-head [ x86_64 ]
|
|
55
|
+
* rbx-2 [ x86_64 ]
|
|
56
|
+
|
|
57
|
+
Testing a specific mime type (needed for 1.8.7 for example) can be done manually with:
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
BUNDLE_GEMFILE=gemfiles/mime_types_1.16.gemfile (bundle check || bundle) && rake
|
|
61
|
+
```
|
|
53
62
|
|
|
54
63
|
Discussion
|
|
55
64
|
----------
|
|
@@ -104,7 +113,7 @@ It also means you can be sure Mail will behave correctly.
|
|
|
104
113
|
API Policy
|
|
105
114
|
----------
|
|
106
115
|
|
|
107
|
-
No API removals within a single point release. All removals to be
|
|
116
|
+
No API removals within a single point release. All removals to be deprecated with
|
|
108
117
|
warnings for at least one MINOR point release before removal.
|
|
109
118
|
|
|
110
119
|
Also, all private or protected methods to be declared as such - though this is still I/P.
|
|
@@ -129,12 +138,12 @@ I have tried to simplify it some:
|
|
|
129
138
|
it will include the header field and value and CRLF at the end and wrapped as
|
|
130
139
|
needed.
|
|
131
140
|
|
|
132
|
-
2. All objects that can render into an email, have a
|
|
141
|
+
2. All objects that can render into an email, have a `#decoded` method. Decoded will
|
|
133
142
|
return the object's "value" only as a string. This means it will not include
|
|
134
143
|
the header fields (like 'To:' or 'Subject:').
|
|
135
144
|
|
|
136
145
|
3. By default, calling <code>#to_s</code> on a container object will call its encoded
|
|
137
|
-
method, while <code>#to_s</code> on a field object will call
|
|
146
|
+
method, while <code>#to_s</code> on a field object will call its decoded method.
|
|
138
147
|
So calling <code>#to_s</code> on a Mail object will return the mail, all encoded
|
|
139
148
|
ready to send, while calling <code>#to_s</code> on the From field or the body will
|
|
140
149
|
return the decoded value of the object. The header object of Mail is considered a
|
|
@@ -184,6 +193,8 @@ mail['from'] = 'mikel@test.lindsaar.net'
|
|
|
184
193
|
mail[:to] = 'you@test.lindsaar.net'
|
|
185
194
|
mail.subject = 'This is a test email'
|
|
186
195
|
|
|
196
|
+
mail.header['X-Custom-Header'] = 'custom value'
|
|
197
|
+
|
|
187
198
|
mail.to_s #=> "From: mikel@test.lindsaar.net\r\nTo: you@...
|
|
188
199
|
```
|
|
189
200
|
|
|
@@ -201,7 +212,7 @@ mail.to_s =~ /Message\-ID: <[\d\w_]+@.+.mail/ #=> 27
|
|
|
201
212
|
Mail will automatically add a Message-ID field if it is missing and
|
|
202
213
|
give it a unique, random Message-ID along the lines of:
|
|
203
214
|
|
|
204
|
-
<4a7ff76d7016_13a81ab802e1@local.
|
|
215
|
+
<4a7ff76d7016_13a81ab802e1@local.host.mail>
|
|
205
216
|
|
|
206
217
|
### Or do worry about Message-IDs:
|
|
207
218
|
|
|
@@ -226,10 +237,10 @@ easy as:
|
|
|
226
237
|
|
|
227
238
|
```ruby
|
|
228
239
|
Mail.deliver do
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
240
|
+
from 'me@test.lindsaar.net'
|
|
241
|
+
to 'you@test.lindsaar.net'
|
|
242
|
+
subject 'Here is the image you wanted'
|
|
243
|
+
body File.read('body.txt')
|
|
233
244
|
add_file '/full/path/to/somefile.png'
|
|
234
245
|
end
|
|
235
246
|
```
|
|
@@ -264,7 +275,16 @@ mail.delivery_method :sendmail
|
|
|
264
275
|
mail.deliver
|
|
265
276
|
```
|
|
266
277
|
|
|
267
|
-
|
|
278
|
+
Sending via smtp (for example to [mailcatcher](https://github.com/sj26/mailcatcher))
|
|
279
|
+
```ruby
|
|
280
|
+
|
|
281
|
+
Mail.defaults do
|
|
282
|
+
delivery_method :smtp, address: "localhost", port: 1025
|
|
283
|
+
end
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
Exim requires its own delivery manager, and can be used like so:
|
|
268
288
|
|
|
269
289
|
```ruby
|
|
270
290
|
mail.delivery_method :exim, :location => "/usr/bin/exim"
|
|
@@ -294,7 +314,7 @@ The most recent email:
|
|
|
294
314
|
```ruby
|
|
295
315
|
Mail.all #=> Returns an array of all emails
|
|
296
316
|
Mail.first #=> Returns the first unread email
|
|
297
|
-
Mail.last #=> Returns the
|
|
317
|
+
Mail.last #=> Returns the last unread email
|
|
298
318
|
```
|
|
299
319
|
|
|
300
320
|
The first 10 emails sorted by date in ascending order:
|
|
@@ -317,7 +337,7 @@ emails.length #=> LOTS!
|
|
|
317
337
|
```ruby
|
|
318
338
|
mail = Mail.read('/path/to/message.eml')
|
|
319
339
|
|
|
320
|
-
mail.
|
|
340
|
+
mail.envelope_from #=> 'mikel@test.lindsaar.net'
|
|
321
341
|
mail.from.addresses #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
|
|
322
342
|
mail.sender.address #=> 'mikel@test.lindsaar.net'
|
|
323
343
|
mail.to #=> 'bob@test.lindsaar.net'
|
|
@@ -337,8 +357,8 @@ mail = Mail.read('multipart_email')
|
|
|
337
357
|
|
|
338
358
|
mail.multipart? #=> true
|
|
339
359
|
mail.parts.length #=> 2
|
|
340
|
-
mail.preamble
|
|
341
|
-
mail.epilogue
|
|
360
|
+
mail.body.preamble #=> "Text before the first part"
|
|
361
|
+
mail.body.epilogue #=> "Text after the last part"
|
|
342
362
|
mail.parts.map { |p| p.content_type } #=> ['text/plain', 'application/pdf']
|
|
343
363
|
mail.parts.map { |p| p.class } #=> [Mail::Message, Mail::Message]
|
|
344
364
|
mail.parts[0].content_type_parameters #=> {'charset' => 'ISO-8859-1'}
|
|
@@ -348,7 +368,7 @@ mail.parts[1].content_type_parameters #=> {'name' => 'my.pdf'}
|
|
|
348
368
|
Mail generates a tree of parts. Each message has many or no parts. Each part
|
|
349
369
|
is another message which can have many or no parts.
|
|
350
370
|
|
|
351
|
-
A message will only have parts if it is a multipart/mixed or related
|
|
371
|
+
A message will only have parts if it is a multipart/mixed or multipart/related
|
|
352
372
|
content type and has a boundary defined.
|
|
353
373
|
|
|
354
374
|
### Testing and extracting attachments
|
|
@@ -361,7 +381,7 @@ mail.attachments.each do | attachment |
|
|
|
361
381
|
filename = attachment.filename
|
|
362
382
|
begin
|
|
363
383
|
File.open(images_dir + filename, "w+b", 0644) {|f| f.write attachment.body.decoded}
|
|
364
|
-
rescue
|
|
384
|
+
rescue => e
|
|
365
385
|
puts "Unable to save data for #{filename} because #{e.message}"
|
|
366
386
|
end
|
|
367
387
|
end
|
|
@@ -544,7 +564,7 @@ Using Mail with Testing or Spec'ing Libraries
|
|
|
544
564
|
If mail is part of your system, you'll need a way to test it without actually
|
|
545
565
|
sending emails, the TestMailer can do this for you.
|
|
546
566
|
|
|
547
|
-
```
|
|
567
|
+
```ruby
|
|
548
568
|
require 'mail'
|
|
549
569
|
=> true
|
|
550
570
|
Mail.defaults do
|
|
@@ -570,7 +590,7 @@ Mail::TestMailer.deliveries.clear
|
|
|
570
590
|
|
|
571
591
|
There is also a set of RSpec matchers stolen fr^H^H^H^H^H^H^H^H inspired by Shoulda's ActionMailer matchers (you'll want to set <code>delivery_method</code> as above too):
|
|
572
592
|
|
|
573
|
-
```
|
|
593
|
+
```ruby
|
|
574
594
|
Mail.defaults do
|
|
575
595
|
delivery_method :test # in practice you'd do this in spec_helper.rb
|
|
576
596
|
end
|
|
@@ -641,7 +661,7 @@ License
|
|
|
641
661
|
|
|
642
662
|
(The MIT License)
|
|
643
663
|
|
|
644
|
-
Copyright (c) 2009
|
|
664
|
+
Copyright (c) 2009-2013 Mikel Lindsaar
|
|
645
665
|
|
|
646
666
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
647
667
|
a copy of this software and associated documentation files (the
|
data/Rakefile
CHANGED
|
@@ -1,25 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
require "bundler"
|
|
4
|
-
rescue LoadError
|
|
5
|
-
raise "Could not load the bundler gem. Install it with `gem install bundler`."
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("1.0.0")
|
|
9
|
-
raise RuntimeError, "Your bundler version is too old for Mail" +
|
|
10
|
-
"Run `gem install bundler` to upgrade."
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
begin
|
|
14
|
-
# Set up load paths for all bundled gems
|
|
15
|
-
ENV["BUNDLE_GEMFILE"] = File.expand_path("../Gemfile", __FILE__)
|
|
16
|
-
Bundler.setup
|
|
17
|
-
rescue Bundler::GemNotFound
|
|
18
|
-
raise RuntimeError, "Bundler couldn't find some gems." +
|
|
19
|
-
"Did you run `bundle install`?"
|
|
1
|
+
if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"]
|
|
2
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __FILE__)
|
|
20
3
|
end
|
|
21
|
-
|
|
22
|
-
require
|
|
4
|
+
require 'rubygems'
|
|
5
|
+
require 'bundler/setup'
|
|
23
6
|
|
|
24
7
|
require 'rake/testtask'
|
|
25
8
|
require 'rspec/core/rake_task'
|
|
@@ -36,5 +19,11 @@ RSpec::Core::RakeTask.new(:spec) do |t|
|
|
|
36
19
|
t.rspec_opts = %w(--backtrace --color)
|
|
37
20
|
end
|
|
38
21
|
|
|
22
|
+
begin
|
|
23
|
+
require "appraisal"
|
|
24
|
+
rescue LoadError
|
|
25
|
+
warn "Appraisal is only available in test/development"
|
|
26
|
+
end
|
|
27
|
+
|
|
39
28
|
# load custom rake tasks
|
|
40
|
-
Dir["#{File.dirname(__FILE__)}/
|
|
29
|
+
Dir["#{File.dirname(__FILE__)}/tasks/**/*.rake"].sort.each { |ext| load ext }
|
|
@@ -60,7 +60,7 @@ module Mail
|
|
|
60
60
|
if value[:mime_type]
|
|
61
61
|
default_values[:content_type] = value.delete(:mime_type)
|
|
62
62
|
@mime_type = MIME::Types[default_values[:content_type]].first
|
|
63
|
-
default_values[:content_transfer_encoding]
|
|
63
|
+
default_values[:content_transfer_encoding] ||= guess_encoding
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
hash = default_values.merge(value)
|
|
@@ -94,7 +94,7 @@ module Mail
|
|
|
94
94
|
def set_mime_type(filename)
|
|
95
95
|
# Have to do this because MIME::Types is not Ruby 1.9 safe yet
|
|
96
96
|
if RUBY_VERSION >= '1.9'
|
|
97
|
-
|
|
97
|
+
filename = filename.encode(Encoding::UTF_8) if filename.respond_to?(:encode)
|
|
98
98
|
end
|
|
99
99
|
|
|
100
100
|
@mime_type = MIME::Types.type_for(filename).first
|
data/lib/mail/body.rb
CHANGED
|
@@ -5,8 +5,8 @@ module Mail
|
|
|
5
5
|
#
|
|
6
6
|
# The body is where the text of the email is stored. Mail treats the body
|
|
7
7
|
# as a single object. The body itself has no information about boundaries
|
|
8
|
-
# used in the MIME standard, it just looks at
|
|
9
|
-
# block of text, or (if it is a multipart message) as an array of blocks
|
|
8
|
+
# used in the MIME standard, it just looks at its content as either a single
|
|
9
|
+
# block of text, or (if it is a multipart message) as an array of blocks of text.
|
|
10
10
|
#
|
|
11
11
|
# A body has to be told to split itself up into a multipart message by calling
|
|
12
12
|
# #split with the correct boundary. This is because the body object has no way
|
|
@@ -127,9 +127,9 @@ module Mail
|
|
|
127
127
|
def sort_parts!
|
|
128
128
|
@parts.each do |p|
|
|
129
129
|
p.body.set_sort_order(@part_sort_order)
|
|
130
|
-
@parts.sort!(@part_sort_order)
|
|
131
130
|
p.body.sort_parts!
|
|
132
131
|
end
|
|
132
|
+
@parts.sort!(@part_sort_order)
|
|
133
133
|
end
|
|
134
134
|
|
|
135
135
|
# Returns the raw source that the body was initialized with, without
|
|
@@ -254,18 +254,19 @@ module Mail
|
|
|
254
254
|
@parts = Mail::PartsList.new[val]
|
|
255
255
|
end
|
|
256
256
|
end
|
|
257
|
-
|
|
257
|
+
|
|
258
258
|
def split!(boundary)
|
|
259
259
|
self.boundary = boundary
|
|
260
|
-
parts =
|
|
260
|
+
parts = extract_parts
|
|
261
|
+
|
|
261
262
|
# Make the preamble equal to the preamble (if any)
|
|
262
263
|
self.preamble = parts[0].to_s.strip
|
|
263
264
|
# Make the epilogue equal to the epilogue (if any)
|
|
264
|
-
self.epilogue = parts[-1].to_s.
|
|
265
|
+
self.epilogue = parts[-1].to_s.strip
|
|
265
266
|
parts[1...-1].to_a.each { |part| @parts << Mail::Part.new(part) }
|
|
266
267
|
self
|
|
267
268
|
end
|
|
268
|
-
|
|
269
|
+
|
|
269
270
|
def only_us_ascii?
|
|
270
271
|
!(raw_source =~ /[^\x01-\x7f]/)
|
|
271
272
|
end
|
|
@@ -275,13 +276,36 @@ module Mail
|
|
|
275
276
|
end
|
|
276
277
|
|
|
277
278
|
private
|
|
279
|
+
|
|
280
|
+
# split parts by boundary, ignore first part if empty, append final part when closing boundary was missing
|
|
281
|
+
def extract_parts
|
|
282
|
+
parts_regex = /
|
|
283
|
+
(?: # non-capturing group
|
|
284
|
+
\A | # start of string OR
|
|
285
|
+
\r\n # line break
|
|
286
|
+
)
|
|
287
|
+
(
|
|
288
|
+
--#{Regexp.escape(boundary || "")} # boundary delimiter
|
|
289
|
+
(?:--)? # with non-capturing optional closing
|
|
290
|
+
)
|
|
291
|
+
(?=\s*$) # lookahead matching zero or more spaces followed by line-ending
|
|
292
|
+
/x
|
|
293
|
+
parts = raw_source.split(parts_regex).each_slice(2).to_a
|
|
294
|
+
parts.each_with_index { |(part, _), index| parts.delete_at(index) if index > 0 && part.blank? }
|
|
295
|
+
|
|
296
|
+
if parts.size > 1
|
|
297
|
+
final_separator = parts[-2][1]
|
|
298
|
+
parts << [""] if final_separator != "--#{boundary}--"
|
|
299
|
+
end
|
|
300
|
+
parts.map(&:first)
|
|
301
|
+
end
|
|
278
302
|
|
|
279
303
|
def crlf_boundary
|
|
280
|
-
"\r\n
|
|
304
|
+
"\r\n--#{boundary}\r\n"
|
|
281
305
|
end
|
|
282
306
|
|
|
283
307
|
def end_boundary
|
|
284
|
-
"\r\n
|
|
308
|
+
"\r\n--#{boundary}--\r\n"
|
|
285
309
|
end
|
|
286
310
|
|
|
287
311
|
def set_charset
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Mail
|
|
2
|
+
module CheckDeliveryParams
|
|
3
|
+
def check_delivery_params(mail)
|
|
4
|
+
if mail.smtp_envelope_from.blank?
|
|
5
|
+
raise ArgumentError.new('An SMTP From address is required to send a message. Set the message smtp_envelope_from, return_path, sender, or from address.')
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
if mail.smtp_envelope_to.blank?
|
|
9
|
+
raise ArgumentError.new('An SMTP To address is required to send a message. Set the message smtp_envelope_to, to, cc, or bcc address.')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
message = mail.encoded if mail.respond_to?(:encoded)
|
|
13
|
+
if message.blank?
|
|
14
|
+
raise ArgumentError.new('An encoded message is required to send an email')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
[mail.smtp_envelope_from, mail.smtp_envelope_to, message]
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|