kbaum-mail 2.1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +289 -0
- data/README.rdoc +575 -0
- data/Rakefile +72 -0
- data/TODO.rdoc +19 -0
- data/lib/mail.rb +113 -0
- data/lib/mail/attachments_list.rb +76 -0
- data/lib/mail/body.rb +243 -0
- data/lib/mail/configuration.rb +69 -0
- data/lib/mail/core_extensions/nil.rb +11 -0
- data/lib/mail/core_extensions/string.rb +19 -0
- data/lib/mail/elements/address.rb +306 -0
- data/lib/mail/elements/address_list.rb +74 -0
- data/lib/mail/elements/content_disposition_element.rb +30 -0
- data/lib/mail/elements/content_location_element.rb +25 -0
- data/lib/mail/elements/content_transfer_encoding_element.rb +21 -0
- data/lib/mail/elements/content_type_element.rb +35 -0
- data/lib/mail/elements/date_time_element.rb +26 -0
- data/lib/mail/elements/envelope_from_element.rb +34 -0
- data/lib/mail/elements/message_ids_element.rb +29 -0
- data/lib/mail/elements/mime_version_element.rb +26 -0
- data/lib/mail/elements/phrase_list.rb +21 -0
- data/lib/mail/elements/received_element.rb +30 -0
- data/lib/mail/encodings/base64.rb +18 -0
- data/lib/mail/encodings/encodings.rb +201 -0
- data/lib/mail/encodings/quoted_printable.rb +26 -0
- data/lib/mail/envelope.rb +35 -0
- data/lib/mail/field.rb +219 -0
- data/lib/mail/field_list.rb +33 -0
- data/lib/mail/fields/bcc_field.rb +53 -0
- data/lib/mail/fields/cc_field.rb +52 -0
- data/lib/mail/fields/comments_field.rb +41 -0
- data/lib/mail/fields/common/address_container.rb +16 -0
- data/lib/mail/fields/common/common_address.rb +128 -0
- data/lib/mail/fields/common/common_date.rb +51 -0
- data/lib/mail/fields/common/common_field.rb +64 -0
- data/lib/mail/fields/common/common_message_id.rb +57 -0
- data/lib/mail/fields/common/parameter_hash.rb +39 -0
- data/lib/mail/fields/content_description_field.rb +19 -0
- data/lib/mail/fields/content_disposition_field.rb +60 -0
- data/lib/mail/fields/content_id_field.rb +63 -0
- data/lib/mail/fields/content_location_field.rb +42 -0
- data/lib/mail/fields/content_transfer_encoding_field.rb +45 -0
- data/lib/mail/fields/content_type_field.rb +175 -0
- data/lib/mail/fields/date_field.rb +53 -0
- data/lib/mail/fields/from_field.rb +53 -0
- data/lib/mail/fields/in_reply_to_field.rb +52 -0
- data/lib/mail/fields/keywords_field.rb +43 -0
- data/lib/mail/fields/message_id_field.rb +80 -0
- data/lib/mail/fields/mime_version_field.rb +54 -0
- data/lib/mail/fields/optional_field.rb +11 -0
- data/lib/mail/fields/received_field.rb +62 -0
- data/lib/mail/fields/references_field.rb +53 -0
- data/lib/mail/fields/reply_to_field.rb +53 -0
- data/lib/mail/fields/resent_bcc_field.rb +53 -0
- data/lib/mail/fields/resent_cc_field.rb +53 -0
- data/lib/mail/fields/resent_date_field.rb +33 -0
- data/lib/mail/fields/resent_from_field.rb +53 -0
- data/lib/mail/fields/resent_message_id_field.rb +32 -0
- data/lib/mail/fields/resent_sender_field.rb +60 -0
- data/lib/mail/fields/resent_to_field.rb +53 -0
- data/lib/mail/fields/return_path_field.rb +62 -0
- data/lib/mail/fields/sender_field.rb +65 -0
- data/lib/mail/fields/structured_field.rb +36 -0
- data/lib/mail/fields/subject_field.rb +15 -0
- data/lib/mail/fields/to_field.rb +53 -0
- data/lib/mail/fields/unstructured_field.rb +117 -0
- data/lib/mail/header.rb +235 -0
- data/lib/mail/mail.rb +194 -0
- data/lib/mail/message.rb +1780 -0
- data/lib/mail/network/delivery_methods/file_delivery.rb +40 -0
- data/lib/mail/network/delivery_methods/sendmail.rb +62 -0
- data/lib/mail/network/delivery_methods/smtp.rb +110 -0
- data/lib/mail/network/delivery_methods/test_mailer.rb +40 -0
- data/lib/mail/network/retriever_methods/imap.rb +31 -0
- data/lib/mail/network/retriever_methods/pop3.rb +149 -0
- data/lib/mail/parsers/address_lists.rb +61 -0
- data/lib/mail/parsers/address_lists.treetop +19 -0
- data/lib/mail/parsers/content_disposition.rb +369 -0
- data/lib/mail/parsers/content_disposition.treetop +46 -0
- data/lib/mail/parsers/content_location.rb +133 -0
- data/lib/mail/parsers/content_location.treetop +20 -0
- data/lib/mail/parsers/content_transfer_encoding.rb +179 -0
- data/lib/mail/parsers/content_transfer_encoding.treetop +25 -0
- data/lib/mail/parsers/content_type.rb +512 -0
- data/lib/mail/parsers/content_type.treetop +58 -0
- data/lib/mail/parsers/date_time.rb +111 -0
- data/lib/mail/parsers/date_time.treetop +11 -0
- data/lib/mail/parsers/envelope_from.rb +188 -0
- data/lib/mail/parsers/envelope_from.treetop +32 -0
- data/lib/mail/parsers/message_ids.rb +42 -0
- data/lib/mail/parsers/message_ids.treetop +15 -0
- data/lib/mail/parsers/mime_version.rb +141 -0
- data/lib/mail/parsers/mime_version.treetop +19 -0
- data/lib/mail/parsers/phrase_lists.rb +42 -0
- data/lib/mail/parsers/phrase_lists.treetop +15 -0
- data/lib/mail/parsers/received.rb +68 -0
- data/lib/mail/parsers/received.treetop +11 -0
- data/lib/mail/parsers/rfc2045.rb +406 -0
- data/lib/mail/parsers/rfc2045.treetop +35 -0
- data/lib/mail/parsers/rfc2822.rb +5081 -0
- data/lib/mail/parsers/rfc2822.treetop +410 -0
- data/lib/mail/parsers/rfc2822_obsolete.rb +3607 -0
- data/lib/mail/parsers/rfc2822_obsolete.treetop +241 -0
- data/lib/mail/part.rb +82 -0
- data/lib/mail/parts_list.rb +34 -0
- data/lib/mail/patterns.rb +43 -0
- data/lib/mail/utilities.rb +163 -0
- data/lib/mail/vendor/treetop.rb +4 -0
- data/lib/mail/version.rb +10 -0
- data/lib/mail/version_specific/ruby_1_8.rb +84 -0
- data/lib/mail/version_specific/ruby_1_9.rb +77 -0
- data/lib/tasks/corpus.rake +125 -0
- data/lib/tasks/treetop.rake +10 -0
- metadata +188 -0
@@ -0,0 +1,58 @@
|
|
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
|
+
rule discrete_type
|
22
|
+
"text" / "image" / "audio" / "video" / "application" / extension_token
|
23
|
+
end
|
24
|
+
|
25
|
+
rule composite_type
|
26
|
+
"message" / "multipart" / extension_token
|
27
|
+
end
|
28
|
+
|
29
|
+
rule extension_token
|
30
|
+
ietf_token / x_token
|
31
|
+
end
|
32
|
+
|
33
|
+
rule sub_type
|
34
|
+
extension_token / iana_token
|
35
|
+
end
|
36
|
+
|
37
|
+
rule parameter
|
38
|
+
CFWS? attr:attribute "=" val:value CFWS? {
|
39
|
+
def param_hash
|
40
|
+
{attr.text_value => val.text_value}
|
41
|
+
end
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
rule attribute
|
46
|
+
token+
|
47
|
+
end
|
48
|
+
|
49
|
+
rule value
|
50
|
+
quoted_string {
|
51
|
+
def text_value
|
52
|
+
quoted_content.text_value
|
53
|
+
end
|
54
|
+
} / (token / [\x3d])+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,111 @@
|
|
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
|
+
@index = cached.interval.end if cached
|
41
|
+
return cached
|
42
|
+
end
|
43
|
+
|
44
|
+
i0, s0 = index, []
|
45
|
+
i2, s2 = index, []
|
46
|
+
r3 = _nt_day_of_week
|
47
|
+
s2 << r3
|
48
|
+
if r3
|
49
|
+
if has_terminal?(",", false, index)
|
50
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
51
|
+
@index += 1
|
52
|
+
else
|
53
|
+
terminal_parse_failure(",")
|
54
|
+
r4 = nil
|
55
|
+
end
|
56
|
+
s2 << r4
|
57
|
+
end
|
58
|
+
if s2.last
|
59
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
60
|
+
r2.extend(Primary0)
|
61
|
+
else
|
62
|
+
@index = i2
|
63
|
+
r2 = nil
|
64
|
+
end
|
65
|
+
if r2
|
66
|
+
r1 = r2
|
67
|
+
else
|
68
|
+
r1 = instantiate_node(SyntaxNode,input, index...index)
|
69
|
+
end
|
70
|
+
s0 << r1
|
71
|
+
if r1
|
72
|
+
r5 = _nt_date
|
73
|
+
s0 << r5
|
74
|
+
if r5
|
75
|
+
r6 = _nt_FWS
|
76
|
+
s0 << r6
|
77
|
+
if r6
|
78
|
+
r7 = _nt_time
|
79
|
+
s0 << r7
|
80
|
+
if r7
|
81
|
+
r9 = _nt_CFWS
|
82
|
+
if r9
|
83
|
+
r8 = r9
|
84
|
+
else
|
85
|
+
r8 = instantiate_node(SyntaxNode,input, index...index)
|
86
|
+
end
|
87
|
+
s0 << r8
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
if s0.last
|
93
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
94
|
+
r0.extend(Primary1)
|
95
|
+
else
|
96
|
+
@index = i0
|
97
|
+
r0 = nil
|
98
|
+
end
|
99
|
+
|
100
|
+
node_cache[:primary][start_index] = r0
|
101
|
+
|
102
|
+
r0
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
class DateTimeParser < Treetop::Runtime::CompiledParser
|
108
|
+
include DateTime
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
@@ -0,0 +1,188 @@
|
|
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
|
+
@index = cached.interval.end if cached
|
29
|
+
return cached
|
30
|
+
end
|
31
|
+
|
32
|
+
i0, s0 = index, []
|
33
|
+
r1 = _nt_addr_spec
|
34
|
+
s0 << r1
|
35
|
+
if r1
|
36
|
+
r2 = _nt_ctime_date
|
37
|
+
s0 << r2
|
38
|
+
end
|
39
|
+
if s0.last
|
40
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
41
|
+
r0.extend(Primary0)
|
42
|
+
else
|
43
|
+
@index = i0
|
44
|
+
r0 = nil
|
45
|
+
end
|
46
|
+
|
47
|
+
node_cache[:primary][start_index] = r0
|
48
|
+
|
49
|
+
r0
|
50
|
+
end
|
51
|
+
|
52
|
+
module CtimeDate0
|
53
|
+
def day_name
|
54
|
+
elements[0]
|
55
|
+
end
|
56
|
+
|
57
|
+
def month_name
|
58
|
+
elements[2]
|
59
|
+
end
|
60
|
+
|
61
|
+
def day
|
62
|
+
elements[4]
|
63
|
+
end
|
64
|
+
|
65
|
+
def time_of_day
|
66
|
+
elements[6]
|
67
|
+
end
|
68
|
+
|
69
|
+
def year
|
70
|
+
elements[8]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def _nt_ctime_date
|
75
|
+
start_index = index
|
76
|
+
if node_cache[:ctime_date].has_key?(index)
|
77
|
+
cached = node_cache[:ctime_date][index]
|
78
|
+
@index = cached.interval.end if cached
|
79
|
+
return cached
|
80
|
+
end
|
81
|
+
|
82
|
+
i0, s0 = index, []
|
83
|
+
r1 = _nt_day_name
|
84
|
+
s0 << r1
|
85
|
+
if r1
|
86
|
+
s2, i2 = [], index
|
87
|
+
loop do
|
88
|
+
if has_terminal?(" ", false, index)
|
89
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
90
|
+
@index += 1
|
91
|
+
else
|
92
|
+
terminal_parse_failure(" ")
|
93
|
+
r3 = nil
|
94
|
+
end
|
95
|
+
if r3
|
96
|
+
s2 << r3
|
97
|
+
else
|
98
|
+
break
|
99
|
+
end
|
100
|
+
end
|
101
|
+
if s2.empty?
|
102
|
+
@index = i2
|
103
|
+
r2 = nil
|
104
|
+
else
|
105
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
106
|
+
end
|
107
|
+
s0 << r2
|
108
|
+
if r2
|
109
|
+
r4 = _nt_month_name
|
110
|
+
s0 << r4
|
111
|
+
if r4
|
112
|
+
s5, i5 = [], index
|
113
|
+
loop do
|
114
|
+
if has_terminal?(" ", false, index)
|
115
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
116
|
+
@index += 1
|
117
|
+
else
|
118
|
+
terminal_parse_failure(" ")
|
119
|
+
r6 = nil
|
120
|
+
end
|
121
|
+
if r6
|
122
|
+
s5 << r6
|
123
|
+
else
|
124
|
+
break
|
125
|
+
end
|
126
|
+
end
|
127
|
+
if s5.empty?
|
128
|
+
@index = i5
|
129
|
+
r5 = nil
|
130
|
+
else
|
131
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
132
|
+
end
|
133
|
+
s0 << r5
|
134
|
+
if r5
|
135
|
+
r7 = _nt_day
|
136
|
+
s0 << r7
|
137
|
+
if r7
|
138
|
+
if has_terminal?(" ", false, index)
|
139
|
+
r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
140
|
+
@index += 1
|
141
|
+
else
|
142
|
+
terminal_parse_failure(" ")
|
143
|
+
r8 = nil
|
144
|
+
end
|
145
|
+
s0 << r8
|
146
|
+
if r8
|
147
|
+
r9 = _nt_time_of_day
|
148
|
+
s0 << r9
|
149
|
+
if r9
|
150
|
+
if has_terminal?(" ", false, index)
|
151
|
+
r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
152
|
+
@index += 1
|
153
|
+
else
|
154
|
+
terminal_parse_failure(" ")
|
155
|
+
r10 = nil
|
156
|
+
end
|
157
|
+
s0 << r10
|
158
|
+
if r10
|
159
|
+
r11 = _nt_year
|
160
|
+
s0 << r11
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
if s0.last
|
170
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
171
|
+
r0.extend(CtimeDate0)
|
172
|
+
else
|
173
|
+
@index = i0
|
174
|
+
r0 = nil
|
175
|
+
end
|
176
|
+
|
177
|
+
node_cache[:ctime_date][start_index] = r0
|
178
|
+
|
179
|
+
r0
|
180
|
+
end
|
181
|
+
|
182
|
+
end
|
183
|
+
|
184
|
+
class EnvelopeFromParser < Treetop::Runtime::CompiledParser
|
185
|
+
include EnvelopeFrom
|
186
|
+
end
|
187
|
+
|
188
|
+
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,42 @@
|
|
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
|
+
@index = cached.interval.end if cached
|
25
|
+
return cached
|
26
|
+
end
|
27
|
+
|
28
|
+
r0 = _nt_message_ids
|
29
|
+
r0.extend(Primary0)
|
30
|
+
|
31
|
+
node_cache[:primary][start_index] = r0
|
32
|
+
|
33
|
+
r0
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
class MessageIdsParser < Treetop::Runtime::CompiledParser
|
39
|
+
include MessageIds
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|