otherinbox-mail 2.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. data/CHANGELOG.rdoc +607 -0
  2. data/CONTRIBUTING.md +45 -0
  3. data/Dependencies.txt +3 -0
  4. data/Gemfile +26 -0
  5. data/Gemfile.lock +44 -0
  6. data/README.md +663 -0
  7. data/Rakefile +40 -0
  8. data/TODO.rdoc +9 -0
  9. data/lib/VERSION +4 -0
  10. data/lib/mail.rb +101 -0
  11. data/lib/mail/attachments_list.rb +104 -0
  12. data/lib/mail/body.rb +291 -0
  13. data/lib/mail/configuration.rb +75 -0
  14. data/lib/mail/core_extensions/nil.rb +17 -0
  15. data/lib/mail/core_extensions/object.rb +13 -0
  16. data/lib/mail/core_extensions/shell_escape.rb +56 -0
  17. data/lib/mail/core_extensions/smtp.rb +25 -0
  18. data/lib/mail/core_extensions/string.rb +33 -0
  19. data/lib/mail/core_extensions/string/access.rb +145 -0
  20. data/lib/mail/core_extensions/string/multibyte.rb +78 -0
  21. data/lib/mail/elements.rb +14 -0
  22. data/lib/mail/elements/address.rb +306 -0
  23. data/lib/mail/elements/address_list.rb +74 -0
  24. data/lib/mail/elements/content_disposition_element.rb +30 -0
  25. data/lib/mail/elements/content_location_element.rb +25 -0
  26. data/lib/mail/elements/content_transfer_encoding_element.rb +24 -0
  27. data/lib/mail/elements/content_type_element.rb +35 -0
  28. data/lib/mail/elements/date_time_element.rb +26 -0
  29. data/lib/mail/elements/envelope_from_element.rb +34 -0
  30. data/lib/mail/elements/message_ids_element.rb +29 -0
  31. data/lib/mail/elements/mime_version_element.rb +26 -0
  32. data/lib/mail/elements/phrase_list.rb +21 -0
  33. data/lib/mail/elements/received_element.rb +30 -0
  34. data/lib/mail/encodings.rb +274 -0
  35. data/lib/mail/encodings/7bit.rb +31 -0
  36. data/lib/mail/encodings/8bit.rb +31 -0
  37. data/lib/mail/encodings/base64.rb +33 -0
  38. data/lib/mail/encodings/binary.rb +31 -0
  39. data/lib/mail/encodings/quoted_printable.rb +38 -0
  40. data/lib/mail/encodings/transfer_encoding.rb +58 -0
  41. data/lib/mail/envelope.rb +35 -0
  42. data/lib/mail/field.rb +234 -0
  43. data/lib/mail/field_list.rb +33 -0
  44. data/lib/mail/fields.rb +35 -0
  45. data/lib/mail/fields/bcc_field.rb +56 -0
  46. data/lib/mail/fields/cc_field.rb +55 -0
  47. data/lib/mail/fields/comments_field.rb +41 -0
  48. data/lib/mail/fields/common/address_container.rb +16 -0
  49. data/lib/mail/fields/common/common_address.rb +125 -0
  50. data/lib/mail/fields/common/common_date.rb +42 -0
  51. data/lib/mail/fields/common/common_field.rb +51 -0
  52. data/lib/mail/fields/common/common_message_id.rb +44 -0
  53. data/lib/mail/fields/common/parameter_hash.rb +58 -0
  54. data/lib/mail/fields/content_description_field.rb +19 -0
  55. data/lib/mail/fields/content_disposition_field.rb +69 -0
  56. data/lib/mail/fields/content_id_field.rb +63 -0
  57. data/lib/mail/fields/content_location_field.rb +42 -0
  58. data/lib/mail/fields/content_transfer_encoding_field.rb +50 -0
  59. data/lib/mail/fields/content_type_field.rb +198 -0
  60. data/lib/mail/fields/date_field.rb +57 -0
  61. data/lib/mail/fields/from_field.rb +55 -0
  62. data/lib/mail/fields/in_reply_to_field.rb +55 -0
  63. data/lib/mail/fields/keywords_field.rb +44 -0
  64. data/lib/mail/fields/message_id_field.rb +83 -0
  65. data/lib/mail/fields/mime_version_field.rb +53 -0
  66. data/lib/mail/fields/optional_field.rb +13 -0
  67. data/lib/mail/fields/received_field.rb +75 -0
  68. data/lib/mail/fields/references_field.rb +55 -0
  69. data/lib/mail/fields/reply_to_field.rb +55 -0
  70. data/lib/mail/fields/resent_bcc_field.rb +55 -0
  71. data/lib/mail/fields/resent_cc_field.rb +55 -0
  72. data/lib/mail/fields/resent_date_field.rb +35 -0
  73. data/lib/mail/fields/resent_from_field.rb +55 -0
  74. data/lib/mail/fields/resent_message_id_field.rb +34 -0
  75. data/lib/mail/fields/resent_sender_field.rb +62 -0
  76. data/lib/mail/fields/resent_to_field.rb +55 -0
  77. data/lib/mail/fields/return_path_field.rb +65 -0
  78. data/lib/mail/fields/sender_field.rb +67 -0
  79. data/lib/mail/fields/structured_field.rb +51 -0
  80. data/lib/mail/fields/subject_field.rb +16 -0
  81. data/lib/mail/fields/to_field.rb +55 -0
  82. data/lib/mail/fields/unstructured_field.rb +191 -0
  83. data/lib/mail/header.rb +265 -0
  84. data/lib/mail/indifferent_hash.rb +146 -0
  85. data/lib/mail/mail.rb +255 -0
  86. data/lib/mail/matchers/has_sent_mail.rb +124 -0
  87. data/lib/mail/message.rb +2059 -0
  88. data/lib/mail/multibyte.rb +42 -0
  89. data/lib/mail/multibyte/chars.rb +474 -0
  90. data/lib/mail/multibyte/exceptions.rb +8 -0
  91. data/lib/mail/multibyte/unicode.rb +392 -0
  92. data/lib/mail/multibyte/utils.rb +60 -0
  93. data/lib/mail/network.rb +14 -0
  94. data/lib/mail/network/delivery_methods/exim.rb +53 -0
  95. data/lib/mail/network/delivery_methods/file_delivery.rb +40 -0
  96. data/lib/mail/network/delivery_methods/sendmail.rb +62 -0
  97. data/lib/mail/network/delivery_methods/smtp.rb +153 -0
  98. data/lib/mail/network/delivery_methods/smtp_connection.rb +74 -0
  99. data/lib/mail/network/delivery_methods/test_mailer.rb +40 -0
  100. data/lib/mail/network/retriever_methods/base.rb +63 -0
  101. data/lib/mail/network/retriever_methods/imap.rb +168 -0
  102. data/lib/mail/network/retriever_methods/pop3.rb +140 -0
  103. data/lib/mail/network/retriever_methods/test_retriever.rb +47 -0
  104. data/lib/mail/parsers/address_lists.rb +64 -0
  105. data/lib/mail/parsers/address_lists.treetop +19 -0
  106. data/lib/mail/parsers/content_disposition.rb +535 -0
  107. data/lib/mail/parsers/content_disposition.treetop +46 -0
  108. data/lib/mail/parsers/content_location.rb +139 -0
  109. data/lib/mail/parsers/content_location.treetop +20 -0
  110. data/lib/mail/parsers/content_transfer_encoding.rb +162 -0
  111. data/lib/mail/parsers/content_transfer_encoding.treetop +20 -0
  112. data/lib/mail/parsers/content_type.rb +967 -0
  113. data/lib/mail/parsers/content_type.treetop +68 -0
  114. data/lib/mail/parsers/date_time.rb +114 -0
  115. data/lib/mail/parsers/date_time.treetop +11 -0
  116. data/lib/mail/parsers/envelope_from.rb +194 -0
  117. data/lib/mail/parsers/envelope_from.treetop +32 -0
  118. data/lib/mail/parsers/message_ids.rb +45 -0
  119. data/lib/mail/parsers/message_ids.treetop +15 -0
  120. data/lib/mail/parsers/mime_version.rb +144 -0
  121. data/lib/mail/parsers/mime_version.treetop +19 -0
  122. data/lib/mail/parsers/phrase_lists.rb +45 -0
  123. data/lib/mail/parsers/phrase_lists.treetop +15 -0
  124. data/lib/mail/parsers/received.rb +71 -0
  125. data/lib/mail/parsers/received.treetop +11 -0
  126. data/lib/mail/parsers/rfc2045.rb +464 -0
  127. data/lib/mail/parsers/rfc2045.treetop +36 -0
  128. data/lib/mail/parsers/rfc2822.rb +5341 -0
  129. data/lib/mail/parsers/rfc2822.treetop +410 -0
  130. data/lib/mail/parsers/rfc2822_obsolete.rb +3768 -0
  131. data/lib/mail/parsers/rfc2822_obsolete.treetop +241 -0
  132. data/lib/mail/part.rb +116 -0
  133. data/lib/mail/parts_list.rb +55 -0
  134. data/lib/mail/patterns.rb +34 -0
  135. data/lib/mail/utilities.rb +215 -0
  136. data/lib/mail/version.rb +24 -0
  137. data/lib/mail/version_specific/ruby_1_8.rb +98 -0
  138. data/lib/mail/version_specific/ruby_1_9.rb +113 -0
  139. data/lib/tasks/corpus.rake +125 -0
  140. data/lib/tasks/treetop.rake +10 -0
  141. metadata +253 -0
@@ -0,0 +1,68 @@
1
+ module Mail
2
+ grammar ContentType
3
+
4
+ include RFC2822
5
+ include RFC2045
6
+
7
+ rule content_type
8
+ main_type "/" sub_type param_hashes:(CFWS ";"? parameter CFWS)* {
9
+ def parameters
10
+ param_hashes.elements.map do |param|
11
+ param.parameter.param_hash
12
+ end
13
+ end
14
+ }
15
+ end
16
+
17
+ rule main_type
18
+ discrete_type / composite_type
19
+ end
20
+
21
+ # This matches in a case insensitive way:
22
+ #
23
+ # rule discrete_type
24
+ # "text" / "image" / "audio" / "video" / "application" / extension_token
25
+ # end
26
+ rule discrete_type
27
+ [tT] [eE] [xX] [tT] / [iI] [mM] [aA] [gG] [eE] / [aA] [uU] [dD] [iI] [oO] / [vV] [iI] [dD] [eE] [oO] / [aA] [pP] [pP] [lL] [iI] [cC] [aA] [tT] [iI] [oO] [nN] / extension_token
28
+ end
29
+
30
+ # This matches in a case insensitive way:
31
+ #
32
+ # rule composite_type
33
+ # "message" / "multipart" / extension_token
34
+ # end
35
+ rule composite_type
36
+ [mM] [eE] [sS] [sS] [aA] [gG] [eE] / [mM] [uU] [lL] [tT] [iI] [pP] [aA] [rR] [tT] / extension_token
37
+ end
38
+
39
+ rule extension_token
40
+ ietf_token / custom_x_token
41
+ end
42
+
43
+ rule sub_type
44
+ extension_token / iana_token
45
+ end
46
+
47
+ rule parameter
48
+ CFWS? attr:attribute "=" val:value CFWS? {
49
+ def param_hash
50
+ {attr.text_value => val.text_value}
51
+ end
52
+ }
53
+ end
54
+
55
+ rule attribute
56
+ token+
57
+ end
58
+
59
+ rule value
60
+ quoted_string {
61
+ def text_value
62
+ quoted_content.text_value
63
+ end
64
+ } / (token / [\x3d])+
65
+ end
66
+
67
+ end
68
+ end
@@ -0,0 +1,114 @@
1
+ # Autogenerated from a Treetop grammar. Edits may be lost.
2
+
3
+
4
+ module Mail
5
+ module DateTime
6
+ include Treetop::Runtime
7
+
8
+ def root
9
+ @root ||= :primary
10
+ end
11
+
12
+ include RFC2822
13
+
14
+ module Primary0
15
+ def day_of_week
16
+ elements[0]
17
+ end
18
+
19
+ end
20
+
21
+ module Primary1
22
+ def date
23
+ elements[1]
24
+ end
25
+
26
+ def FWS
27
+ elements[2]
28
+ end
29
+
30
+ def time
31
+ elements[3]
32
+ end
33
+
34
+ end
35
+
36
+ def _nt_primary
37
+ start_index = index
38
+ if node_cache[:primary].has_key?(index)
39
+ cached = node_cache[:primary][index]
40
+ if cached
41
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
42
+ @index = cached.interval.end
43
+ end
44
+ return cached
45
+ end
46
+
47
+ i0, s0 = index, []
48
+ i2, s2 = index, []
49
+ r3 = _nt_day_of_week
50
+ s2 << r3
51
+ if r3
52
+ if has_terminal?(",", false, index)
53
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
54
+ @index += 1
55
+ else
56
+ terminal_parse_failure(",")
57
+ r4 = nil
58
+ end
59
+ s2 << r4
60
+ end
61
+ if s2.last
62
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
63
+ r2.extend(Primary0)
64
+ else
65
+ @index = i2
66
+ r2 = nil
67
+ end
68
+ if r2
69
+ r1 = r2
70
+ else
71
+ r1 = instantiate_node(SyntaxNode,input, index...index)
72
+ end
73
+ s0 << r1
74
+ if r1
75
+ r5 = _nt_date
76
+ s0 << r5
77
+ if r5
78
+ r6 = _nt_FWS
79
+ s0 << r6
80
+ if r6
81
+ r7 = _nt_time
82
+ s0 << r7
83
+ if r7
84
+ r9 = _nt_CFWS
85
+ if r9
86
+ r8 = r9
87
+ else
88
+ r8 = instantiate_node(SyntaxNode,input, index...index)
89
+ end
90
+ s0 << r8
91
+ end
92
+ end
93
+ end
94
+ end
95
+ if s0.last
96
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
97
+ r0.extend(Primary1)
98
+ else
99
+ @index = i0
100
+ r0 = nil
101
+ end
102
+
103
+ node_cache[:primary][start_index] = r0
104
+
105
+ r0
106
+ end
107
+
108
+ end
109
+
110
+ class DateTimeParser < Treetop::Runtime::CompiledParser
111
+ include DateTime
112
+ end
113
+
114
+ end
@@ -0,0 +1,11 @@
1
+ module Mail
2
+ grammar DateTime
3
+
4
+ include RFC2822
5
+
6
+ rule primary
7
+ ( day_of_week ",")? date FWS time CFWS?
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,194 @@
1
+ # Autogenerated from a Treetop grammar. Edits may be lost.
2
+
3
+
4
+ module Mail
5
+ module EnvelopeFrom
6
+ include Treetop::Runtime
7
+
8
+ def root
9
+ @root ||= :primary
10
+ end
11
+
12
+ include RFC2822
13
+
14
+ module Primary0
15
+ def addr_spec
16
+ elements[0]
17
+ end
18
+
19
+ def ctime_date
20
+ elements[1]
21
+ end
22
+ end
23
+
24
+ def _nt_primary
25
+ start_index = index
26
+ if node_cache[:primary].has_key?(index)
27
+ cached = node_cache[:primary][index]
28
+ if cached
29
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
30
+ @index = cached.interval.end
31
+ end
32
+ return cached
33
+ end
34
+
35
+ i0, s0 = index, []
36
+ r1 = _nt_addr_spec
37
+ s0 << r1
38
+ if r1
39
+ r2 = _nt_ctime_date
40
+ s0 << r2
41
+ end
42
+ if s0.last
43
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
44
+ r0.extend(Primary0)
45
+ else
46
+ @index = i0
47
+ r0 = nil
48
+ end
49
+
50
+ node_cache[:primary][start_index] = r0
51
+
52
+ r0
53
+ end
54
+
55
+ module CtimeDate0
56
+ def day_name
57
+ elements[0]
58
+ end
59
+
60
+ def month_name
61
+ elements[2]
62
+ end
63
+
64
+ def day
65
+ elements[4]
66
+ end
67
+
68
+ def time_of_day
69
+ elements[6]
70
+ end
71
+
72
+ def year
73
+ elements[8]
74
+ end
75
+ end
76
+
77
+ def _nt_ctime_date
78
+ start_index = index
79
+ if node_cache[:ctime_date].has_key?(index)
80
+ cached = node_cache[:ctime_date][index]
81
+ if cached
82
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
83
+ @index = cached.interval.end
84
+ end
85
+ return cached
86
+ end
87
+
88
+ i0, s0 = index, []
89
+ r1 = _nt_day_name
90
+ s0 << r1
91
+ if r1
92
+ s2, i2 = [], index
93
+ loop do
94
+ if has_terminal?(" ", false, index)
95
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
96
+ @index += 1
97
+ else
98
+ terminal_parse_failure(" ")
99
+ r3 = nil
100
+ end
101
+ if r3
102
+ s2 << r3
103
+ else
104
+ break
105
+ end
106
+ end
107
+ if s2.empty?
108
+ @index = i2
109
+ r2 = nil
110
+ else
111
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
112
+ end
113
+ s0 << r2
114
+ if r2
115
+ r4 = _nt_month_name
116
+ s0 << r4
117
+ if r4
118
+ s5, i5 = [], index
119
+ loop do
120
+ if has_terminal?(" ", false, index)
121
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
122
+ @index += 1
123
+ else
124
+ terminal_parse_failure(" ")
125
+ r6 = nil
126
+ end
127
+ if r6
128
+ s5 << r6
129
+ else
130
+ break
131
+ end
132
+ end
133
+ if s5.empty?
134
+ @index = i5
135
+ r5 = nil
136
+ else
137
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
138
+ end
139
+ s0 << r5
140
+ if r5
141
+ r7 = _nt_day
142
+ s0 << r7
143
+ if r7
144
+ if has_terminal?(" ", false, index)
145
+ r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
146
+ @index += 1
147
+ else
148
+ terminal_parse_failure(" ")
149
+ r8 = nil
150
+ end
151
+ s0 << r8
152
+ if r8
153
+ r9 = _nt_time_of_day
154
+ s0 << r9
155
+ if r9
156
+ if has_terminal?(" ", false, index)
157
+ r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
158
+ @index += 1
159
+ else
160
+ terminal_parse_failure(" ")
161
+ r10 = nil
162
+ end
163
+ s0 << r10
164
+ if r10
165
+ r11 = _nt_year
166
+ s0 << r11
167
+ end
168
+ end
169
+ end
170
+ end
171
+ end
172
+ end
173
+ end
174
+ end
175
+ if s0.last
176
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
177
+ r0.extend(CtimeDate0)
178
+ else
179
+ @index = i0
180
+ r0 = nil
181
+ end
182
+
183
+ node_cache[:ctime_date][start_index] = r0
184
+
185
+ r0
186
+ end
187
+
188
+ end
189
+
190
+ class EnvelopeFromParser < Treetop::Runtime::CompiledParser
191
+ include EnvelopeFrom
192
+ end
193
+
194
+ end
@@ -0,0 +1,32 @@
1
+ module Mail
2
+ grammar EnvelopeFrom
3
+
4
+ include RFC2822
5
+
6
+ # The exact character sequence of "From";
7
+ #
8
+ # a single Space character (0x20);
9
+ #
10
+ # the email address of the message sender (as obtained from the
11
+ # message envelope or other authoritative source), conformant
12
+ # with the "addr-spec" syntax from RFC 2822;
13
+ #
14
+ # a single Space character;
15
+ #
16
+ # a timestamp indicating the UTC date and time when the message
17
+ # was originally received, conformant with the syntax of the
18
+ # traditional UNIX 'ctime' output sans timezone (note that the
19
+ # use of UTC precludes the need for a timezone indicator);
20
+ # Thu Nov 24 18:22:48 1986
21
+ #
22
+ # an end-of-line marker.
23
+ rule primary
24
+ addr_spec ctime_date
25
+ end
26
+
27
+ rule ctime_date
28
+ day_name " "+ month_name " "+ day " " time_of_day " " year
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,45 @@
1
+ # Autogenerated from a Treetop grammar. Edits may be lost.
2
+
3
+
4
+ module Mail
5
+ module MessageIds
6
+ include Treetop::Runtime
7
+
8
+ def root
9
+ @root ||= :primary
10
+ end
11
+
12
+ include RFC2822
13
+
14
+ module Primary0
15
+ def message_ids
16
+ [first_msg_id] + other_msg_ids.elements.map { |o| o.msg_id_value }
17
+ end
18
+ end
19
+
20
+ def _nt_primary
21
+ start_index = index
22
+ if node_cache[:primary].has_key?(index)
23
+ cached = node_cache[:primary][index]
24
+ if cached
25
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
26
+ @index = cached.interval.end
27
+ end
28
+ return cached
29
+ end
30
+
31
+ r0 = _nt_message_ids
32
+ r0.extend(Primary0)
33
+
34
+ node_cache[:primary][start_index] = r0
35
+
36
+ r0
37
+ end
38
+
39
+ end
40
+
41
+ class MessageIdsParser < Treetop::Runtime::CompiledParser
42
+ include MessageIds
43
+ end
44
+
45
+ end