mail 2.2.5.1 → 2.2.5.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of mail might be problematic. Click here for more details.
- data/CHANGELOG.rdoc +18 -0
- data/lib/VERSION +1 -1
- data/lib/mail.rb +2 -2
- data/lib/mail/body.rb +0 -1
- data/lib/mail/field_list.rb +1 -1
- data/lib/mail/fields/content_disposition_field.rb +1 -1
- data/lib/mail/fields/content_type_field.rb +36 -23
- data/lib/mail/mail.rb +55 -51
- data/lib/mail/message.rb +405 -375
- data/lib/mail/network/retriever_methods/pop3.rb +1 -1
- data/lib/mail/part.rb +1 -1
- data/lib/mail/patterns.rb +4 -0
- data/lib/mail/version.rb +10 -8
- data/lib/mail/version_specific/ruby_1_8.rb +1 -1
- data/lib/mail/version_specific/ruby_1_9.rb +1 -1
- metadata +3 -102
- data/lib/mail.rbc +0 -1151
- data/lib/mail/attachments_list.rbc +0 -1983
- data/lib/mail/body.rbc +0 -3809
- data/lib/mail/configuration.rbc +0 -1112
- data/lib/mail/core_extensions/nil.rbc +0 -244
- data/lib/mail/core_extensions/string.rbc +0 -0
- data/lib/mail/elements.rbc +0 -362
- data/lib/mail/elements/address.rbc +0 -4112
- data/lib/mail/elements/address_list.rbc +0 -1309
- data/lib/mail/elements/content_disposition_element.rbc +0 -701
- data/lib/mail/elements/content_location_element.rbc +0 -573
- data/lib/mail/elements/content_transfer_encoding_element.rbc +0 -535
- data/lib/mail/elements/content_type_element.rbc +0 -786
- data/lib/mail/elements/date_time_element.rbc +0 -583
- data/lib/mail/elements/envelope_from_element.rbc +0 -771
- data/lib/mail/elements/message_ids_element.rbc +0 -740
- data/lib/mail/elements/mime_version_element.rbc +0 -583
- data/lib/mail/elements/phrase_list.rbc +0 -562
- data/lib/mail/elements/received_element.rbc +0 -725
- data/lib/mail/encodings.rbc +0 -0
- data/lib/mail/encodings/7bit.rbc +0 -538
- data/lib/mail/encodings/8bit.rbc +0 -541
- data/lib/mail/encodings/base64.rbc +0 -629
- data/lib/mail/encodings/binary.rbc +0 -529
- data/lib/mail/encodings/quoted_printable.rbc +0 -766
- data/lib/mail/encodings/transfer_encoding.rbc +0 -1134
- data/lib/mail/envelope.rbc +0 -719
- data/lib/mail/field.rbc +0 -4708
- data/lib/mail/field_list.rbc +0 -518
- data/lib/mail/fields.rbc +0 -782
- data/lib/mail/fields/bcc_field.rbc +0 -564
- data/lib/mail/fields/cc_field.rbc +0 -579
- data/lib/mail/fields/comments_field.rbc +0 -383
- data/lib/mail/fields/common/address_container.rbc +0 -363
- data/lib/mail/fields/common/common_address.rbc +0 -3550
- data/lib/mail/fields/common/common_date.rbc +0 -908
- data/lib/mail/fields/common/common_field.rbc +0 -973
- data/lib/mail/fields/common/common_message_id.rbc +0 -1051
- data/lib/mail/fields/common/parameter_hash.rbc +0 -1335
- data/lib/mail/fields/content_description_field.rbc +0 -396
- data/lib/mail/fields/content_disposition_field.rbc +0 -1440
- data/lib/mail/fields/content_id_field.rbc +0 -1236
- data/lib/mail/fields/content_location_field.rbc +0 -892
- data/lib/mail/fields/content_transfer_encoding_field.rbc +0 -1184
- data/lib/mail/fields/content_type_field.rbc +0 -3958
- data/lib/mail/fields/date_field.rbc +0 -712
- data/lib/mail/fields/from_field.rbc +0 -579
- data/lib/mail/fields/in_reply_to_field.rbc +0 -579
- data/lib/mail/fields/keywords_field.rbc +0 -979
- data/lib/mail/fields/message_id_field.rbc +0 -1008
- data/lib/mail/fields/mime_version_field.rbc +0 -1107
- data/lib/mail/fields/optional_field.rbc +0 -153
- data/lib/mail/fields/received_field.rbc +0 -1137
- data/lib/mail/fields/references_field.rbc +0 -574
- data/lib/mail/fields/reply_to_field.rbc +0 -579
- data/lib/mail/fields/resent_bcc_field.rbc +0 -579
- data/lib/mail/fields/resent_cc_field.rbc +0 -579
- data/lib/mail/fields/resent_date_field.rbc +0 -656
- data/lib/mail/fields/resent_from_field.rbc +0 -579
- data/lib/mail/fields/resent_message_id_field.rbc +0 -639
- data/lib/mail/fields/resent_sender_field.rbc +0 -731
- data/lib/mail/fields/resent_to_field.rbc +0 -579
- data/lib/mail/fields/return_path_field.rbc +0 -737
- data/lib/mail/fields/sender_field.rbc +0 -799
- data/lib/mail/fields/structured_field.rbc +0 -671
- data/lib/mail/fields/subject_field.rbc +0 -378
- data/lib/mail/fields/to_field.rbc +0 -579
- data/lib/mail/fields/unstructured_field.rbc +0 -2292
- data/lib/mail/header.rbc +0 -3720
- data/lib/mail/mail.rbc +0 -2168
- data/lib/mail/message.rbc +0 -19034
- data/lib/mail/network.rbc +0 -236
- data/lib/mail/network/delivery_methods/file_delivery.rbc +0 -722
- data/lib/mail/network/delivery_methods/sendmail.rbc +0 -800
- data/lib/mail/network/delivery_methods/smtp.rbc +0 -1081
- data/lib/mail/network/delivery_methods/test_mailer.rbc +0 -552
- data/lib/mail/network/retriever_methods/pop3.rbc +0 -2447
- data/lib/mail/parsers/address_lists.rbc +0 -1307
- data/lib/mail/parsers/content_disposition.rbc +0 -5968
- data/lib/mail/parsers/content_location.rbc +0 -2166
- data/lib/mail/parsers/content_transfer_encoding.rbc +0 -2591
- data/lib/mail/parsers/content_type.rbc +0 -7949
- data/lib/mail/parsers/date_time.rbc +0 -1836
- data/lib/mail/parsers/envelope_from.rbc +0 -3106
- data/lib/mail/parsers/message_ids.rbc +0 -989
- data/lib/mail/parsers/mime_version.rbc +0 -2254
- data/lib/mail/parsers/phrase_lists.rbc +0 -989
- data/lib/mail/parsers/received.rbc +0 -1267
- data/lib/mail/parsers/rfc2045.rbc +0 -5614
- data/lib/mail/parsers/rfc2822.rbc +0 -74848
- data/lib/mail/parsers/rfc2822_obsolete.rbc +0 -55220
- data/lib/mail/part.rbc +0 -2314
- data/lib/mail/parts_list.rbc +0 -832
- data/lib/mail/patterns.rbc +0 -0
- data/lib/mail/utilities.rbc +0 -2377
- data/lib/mail/version.rbc +0 -450
- data/lib/mail/version_specific/ruby_1_8.rbc +0 -2496
- data/lib/tasks/corpus.rake.compiled.rbc +0 -2195
- data/lib/tasks/treetop.rake.compiled.rbc +0 -297
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
== Sat Sep 11 01:56:59 UTC 2010 Mikel Lindsaar <mikel@rubyx.com>
|
2
|
+
|
3
|
+
* Added new way to do versioning for rubygems
|
4
|
+
* Added additional specs for Content-Disposition: inline which are not being encoded correctly - Shawn Pyle
|
5
|
+
* Make sure Mail::Message#attachment? returns true/false - Simone Carletti
|
6
|
+
* Replace hard-coded references to Mail with more generic self references to allow easier inheritance (closes #61) - Simone Carletti
|
7
|
+
* Force encoding on Regexp for Ruby 1.9 to avoid encoding conflicts - Golubev Pavel
|
8
|
+
* Added lazy evaluation to message body: body is not parsed until need. It greatly improves performance with big mails if you don't need to read the body (yet)
|
9
|
+
* Added Mail.read_from_string as an explicit method (mcansky)
|
10
|
+
* Fixed bounce detection for multipart reports that contain a human readable report status part
|
11
|
+
* Closed Issue #65 found (incredibly) by quetz - major Kudos for bug hunting
|
12
|
+
* Fixed missing trailing CRLF in content type field - Closes issue #57 - Kudos to Henry Flower for finding it
|
13
|
+
|
14
|
+
== Sat Sep 11 01:32:13 UTC 2010 Mikel Lindsaar <mikel@rubyx.com>
|
15
|
+
|
16
|
+
* Closed issue #58 - Content Type not parsing unless lower case.
|
17
|
+
* Version bump to 2.2.5.1
|
18
|
+
|
1
19
|
== Thu 17 Jun 2010 22:13:18 UTC Mikel Lindsaar <mikel@rubyx.com>
|
2
20
|
|
3
21
|
* Added Mail::POP3.delete_all, including specs (Martijn Storck)
|
data/lib/VERSION
CHANGED
data/lib/mail.rb
CHANGED
@@ -22,10 +22,10 @@ module Mail # :doc:
|
|
22
22
|
|
23
23
|
if RUBY_VERSION >= "1.9.1"
|
24
24
|
require 'mail/version_specific/ruby_1_9'
|
25
|
-
RubyVer =
|
25
|
+
RubyVer = Ruby19
|
26
26
|
else
|
27
27
|
require 'mail/version_specific/ruby_1_8'
|
28
|
-
RubyVer =
|
28
|
+
RubyVer = Ruby18
|
29
29
|
end
|
30
30
|
|
31
31
|
require 'mail/version'
|
data/lib/mail/body.rb
CHANGED
data/lib/mail/field_list.rb
CHANGED
@@ -3,10 +3,10 @@ require 'mail/fields/common/parameter_hash'
|
|
3
3
|
|
4
4
|
module Mail
|
5
5
|
class ContentTypeField < StructuredField
|
6
|
-
|
6
|
+
|
7
7
|
FIELD_NAME = 'content-type'
|
8
8
|
CAPITALIZED_FIELD = 'Content-Type'
|
9
|
-
|
9
|
+
|
10
10
|
def initialize(value = nil, charset = 'utf-8')
|
11
11
|
self.charset = charset
|
12
12
|
if value.class == Array
|
@@ -23,15 +23,15 @@ module Mail
|
|
23
23
|
self.parse
|
24
24
|
self
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def parse(val = value)
|
28
28
|
unless val.blank?
|
29
|
-
self.value = val
|
29
|
+
self.value = val
|
30
30
|
@element = nil
|
31
31
|
element
|
32
32
|
end
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
def element
|
36
36
|
begin
|
37
37
|
@element ||= Mail::ContentTypeElement.new(value)
|
@@ -39,7 +39,7 @@ module Mail
|
|
39
39
|
attempt_to_clean
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
def attempt_to_clean
|
44
44
|
# Sanitize the value, handle special cases
|
45
45
|
@element ||= Mail::ContentTypeElement.new(sanatize(value))
|
@@ -47,7 +47,7 @@ module Mail
|
|
47
47
|
# All else fails, just get the MIME media type
|
48
48
|
@element ||= Mail::ContentTypeElement.new(get_mime_type(value))
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
def main_type
|
52
52
|
@main_type ||= element.main_type
|
53
53
|
end
|
@@ -55,17 +55,17 @@ module Mail
|
|
55
55
|
def sub_type
|
56
56
|
@sub_type ||= element.sub_type
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
def string
|
60
60
|
"#{main_type}/#{sub_type}"
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
def default
|
64
64
|
decoded
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
alias :content_type :string
|
68
|
-
|
68
|
+
|
69
69
|
def parameters
|
70
70
|
unless @parameters
|
71
71
|
@parameters = ParameterHash.new
|
@@ -77,7 +77,7 @@ module Mail
|
|
77
77
|
def ContentTypeField.with_boundary(type)
|
78
78
|
new("#{type}; boundary=#{generate_boundary}")
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
def ContentTypeField.generate_boundary
|
82
82
|
"--==_mimepart_#{Mail.random_tag}"
|
83
83
|
end
|
@@ -89,7 +89,7 @@ module Mail
|
|
89
89
|
@value
|
90
90
|
end
|
91
91
|
end
|
92
|
-
|
92
|
+
|
93
93
|
def stringify(params)
|
94
94
|
params.map { |k,v| "#{k}=#{Encodings.param_encode(v)}" }.join("; ")
|
95
95
|
end
|
@@ -100,22 +100,22 @@ module Mail
|
|
100
100
|
@filename = parameters['filename']
|
101
101
|
when parameters['name']
|
102
102
|
@filename = parameters['name']
|
103
|
-
else
|
103
|
+
else
|
104
104
|
@filename = nil
|
105
105
|
end
|
106
106
|
@filename
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
# TODO: Fix this up
|
110
110
|
def encoded
|
111
111
|
if parameters.length > 0
|
112
|
-
p = ";\r\n\s#{parameters.encoded}
|
112
|
+
p = ";\r\n\s#{parameters.encoded}"
|
113
113
|
else
|
114
114
|
p = ""
|
115
115
|
end
|
116
|
-
"#{CAPITALIZED_FIELD}: #{content_type}"
|
116
|
+
"#{CAPITALIZED_FIELD}: #{content_type}#{p}\r\n"
|
117
117
|
end
|
118
|
-
|
118
|
+
|
119
119
|
def decoded
|
120
120
|
if parameters.length > 0
|
121
121
|
p = "; #{parameters.decoded}"
|
@@ -126,7 +126,7 @@ module Mail
|
|
126
126
|
end
|
127
127
|
|
128
128
|
private
|
129
|
-
|
129
|
+
|
130
130
|
def method_missing(name, *args, &block)
|
131
131
|
if name.to_s =~ /([\w_]+)=/
|
132
132
|
self.parameters[$1] = args.first
|
@@ -135,15 +135,28 @@ module Mail
|
|
135
135
|
super
|
136
136
|
end
|
137
137
|
end
|
138
|
-
|
138
|
+
|
139
139
|
# Various special cases from random emails found that I am not going to change
|
140
140
|
# the parser for
|
141
141
|
def sanatize( val )
|
142
|
+
|
143
|
+
# TODO: check if there are cases where whitespace is not a separator
|
144
|
+
val = val.tr(' ',';').
|
145
|
+
squeeze(';').
|
146
|
+
gsub(';', '; '). #use '; ' as a separator (or EOL)
|
147
|
+
gsub(/;\s*$/,'') #remove trailing to keep examples below
|
148
|
+
|
149
|
+
if val =~ /(boundary=(\S*))/i
|
150
|
+
val = "#{$`.downcase}boundary=#{$2}#{$'.downcase}"
|
151
|
+
else
|
152
|
+
val.downcase!
|
153
|
+
end
|
154
|
+
|
142
155
|
case
|
143
156
|
when val.chomp =~ /^\s*([\w\d\-_]+)\/([\w\d\-_]+)\s*;;+(.*)$/i
|
144
157
|
# Handles 'text/plain;; format="flowed"' (double semi colon)
|
145
158
|
"#{$1}/#{$2}; #{$3}"
|
146
|
-
when val.chomp =~ /^\s*([\w\d\-_]+)\/([\w\d\-_]+)\s
|
159
|
+
when val.chomp =~ /^\s*([\w\d\-_]+)\/([\w\d\-_]+)\s*;\s?(ISO[\w\d\-_]+)$/i
|
147
160
|
# Microsoft helper:
|
148
161
|
# Handles 'type/subtype;ISO-8559-1'
|
149
162
|
"#{$1}/#{$2}; charset=#{quote_atom($3)}"
|
@@ -172,12 +185,12 @@ module Mail
|
|
172
185
|
''
|
173
186
|
end
|
174
187
|
end
|
175
|
-
|
188
|
+
|
176
189
|
def get_mime_type( val )
|
177
190
|
case
|
178
191
|
when val =~ /^([\w\d\-_]+)\/([\w\d\-_]+);.+$/i
|
179
192
|
"#{$1}/#{$2}"
|
180
|
-
else
|
193
|
+
else
|
181
194
|
'text/plain'
|
182
195
|
end
|
183
196
|
end
|
data/lib/mail/mail.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module Mail
|
3
|
-
|
3
|
+
|
4
4
|
# Allows you to create a new Mail::Message object.
|
5
5
|
#
|
6
6
|
# You can make an email via passing a string or passing a block.
|
@@ -15,11 +15,11 @@ module Mail
|
|
15
15
|
# string << 'Subject: This is an email\r\n'
|
16
16
|
# string << '\r\n'
|
17
17
|
# string << 'This is the body'
|
18
|
-
#
|
18
|
+
# self.new(string)
|
19
19
|
#
|
20
20
|
# Or creating via a block:
|
21
21
|
#
|
22
|
-
# message =
|
22
|
+
# message = self.new do
|
23
23
|
# to 'mikel@test.lindsaar.net'
|
24
24
|
# from 'bob@test.lindsaar.net'
|
25
25
|
# subject 'This is an email'
|
@@ -28,7 +28,7 @@ module Mail
|
|
28
28
|
#
|
29
29
|
# Or creating via a hash (or hash like object):
|
30
30
|
#
|
31
|
-
# message =
|
31
|
+
# message = self.new({:to => 'mikel@test.lindsaar.net',
|
32
32
|
# 'from' => 'bob@test.lindsaar.net',
|
33
33
|
# :subject 'This is an email',
|
34
34
|
# :body 'This is the body' })
|
@@ -41,13 +41,13 @@ module Mail
|
|
41
41
|
# a Mail::Message object directly and then passing in values via string,
|
42
42
|
# symbol or direct method calls. See Mail::Message for more information.
|
43
43
|
#
|
44
|
-
# mail =
|
44
|
+
# mail = self.new
|
45
45
|
# mail.to = 'mikel@test.lindsaar.net'
|
46
46
|
# mail[:from] = 'bob@test.lindsaar.net'
|
47
47
|
# mail['subject'] = 'This is an email'
|
48
48
|
# mail.body = 'This is the body'
|
49
|
-
def
|
50
|
-
|
49
|
+
def self.new(*args, &block)
|
50
|
+
Message.new(args, &block)
|
51
51
|
end
|
52
52
|
|
53
53
|
# Sets the default delivery method and retriever method for all new Mail objects.
|
@@ -57,7 +57,7 @@ module Mail
|
|
57
57
|
# So sending a new email, if you have an SMTP server running on localhost is
|
58
58
|
# as easy as:
|
59
59
|
#
|
60
|
-
#
|
60
|
+
# self.deliver do
|
61
61
|
# to 'mikel@test.lindsaar.net'
|
62
62
|
# from 'bob@test.lindsaar.net'
|
63
63
|
# subject 'hi there!'
|
@@ -67,7 +67,7 @@ module Mail
|
|
67
67
|
# If you do not specify anything, you will get the following equivalent code set in
|
68
68
|
# every new mail object:
|
69
69
|
#
|
70
|
-
#
|
70
|
+
# self.defaults do
|
71
71
|
# delivery_method :smtp, { :address => "localhost",
|
72
72
|
# :port => 25,
|
73
73
|
# :domain => 'localhost.localdomain',
|
@@ -83,10 +83,10 @@ module Mail
|
|
83
83
|
# :enable_ssl => true }
|
84
84
|
# end
|
85
85
|
#
|
86
|
-
#
|
87
|
-
#
|
86
|
+
# self.delivery_method.new #=> Mail::SMTP instance
|
87
|
+
# self.retriever_method.new #=> Mail::POP3 instance
|
88
88
|
#
|
89
|
-
# Each mail object inherits the default set in
|
89
|
+
# Each mail object inherits the default set in self.delivery_method, however, on
|
90
90
|
# a per email basis, you can override the method:
|
91
91
|
#
|
92
92
|
# mail.delivery_method :sendmail
|
@@ -102,27 +102,27 @@ module Mail
|
|
102
102
|
# The passed in hash is just merged against the defaults with +merge!+ and the result
|
103
103
|
# assigned the mail object. So the above example will change only the :address value
|
104
104
|
# of the global smtp_settings to be 'some.host', keeping all other values
|
105
|
-
def
|
106
|
-
|
105
|
+
def self.defaults(&block)
|
106
|
+
Configuration.instance.instance_eval(&block)
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
# Returns the delivery method selected, defaults to an instance of Mail::SMTP
|
110
|
-
def
|
111
|
-
|
110
|
+
def self.delivery_method
|
111
|
+
Configuration.instance.delivery_method
|
112
112
|
end
|
113
113
|
|
114
114
|
# Returns the retriever method selected, defaults to an instance of Mail::POP3
|
115
|
-
def
|
116
|
-
|
115
|
+
def self.retriever_method
|
116
|
+
Configuration.instance.retriever_method
|
117
117
|
end
|
118
118
|
|
119
119
|
# Send an email using the default configuration. You do need to set a default
|
120
|
-
# configuration first before you use
|
120
|
+
# configuration first before you use self.deliver, if you don't, an appropriate
|
121
121
|
# error will be raised telling you to.
|
122
122
|
#
|
123
123
|
# If you do not specify a delivery type, SMTP will be used.
|
124
124
|
#
|
125
|
-
#
|
125
|
+
# self.deliver do
|
126
126
|
# to 'mikel@test.lindsaar.net'
|
127
127
|
# from 'ada@test.lindsaar.net'
|
128
128
|
# subject 'This is a test email'
|
@@ -131,62 +131,66 @@ module Mail
|
|
131
131
|
#
|
132
132
|
# You can also do:
|
133
133
|
#
|
134
|
-
# mail =
|
134
|
+
# mail = self.read('email.eml')
|
135
135
|
# mail.deliver!
|
136
136
|
#
|
137
137
|
# And your email object will be created and sent.
|
138
|
-
def
|
139
|
-
mail =
|
138
|
+
def self.deliver(*args, &block)
|
139
|
+
mail = self.new(args, &block)
|
140
140
|
mail.deliver
|
141
141
|
mail
|
142
142
|
end
|
143
143
|
|
144
144
|
# Find emails in a POP3 server.
|
145
145
|
# See Mail::POP3 for a complete documentation.
|
146
|
-
def
|
146
|
+
def self.find(*args, &block)
|
147
147
|
retriever_method.find(*args, &block)
|
148
148
|
end
|
149
149
|
|
150
150
|
# Receive the first email(s) from a Pop3 server.
|
151
151
|
# See Mail::POP3 for a complete documentation.
|
152
|
-
def
|
152
|
+
def self.first(*args, &block)
|
153
153
|
retriever_method.first(*args, &block)
|
154
154
|
end
|
155
155
|
|
156
156
|
# Receive the first email(s) from a Pop3 server.
|
157
157
|
# See Mail::POP3 for a complete documentation.
|
158
|
-
def
|
158
|
+
def self.last(*args, &block)
|
159
159
|
retriever_method.last(*args, &block)
|
160
160
|
end
|
161
161
|
|
162
162
|
# Receive all emails from a POP3 server.
|
163
163
|
# See Mail::POP3 for a complete documentation.
|
164
|
-
def
|
164
|
+
def self.all(*args, &block)
|
165
165
|
retriever_method.all(*args, &block)
|
166
166
|
end
|
167
167
|
|
168
168
|
# Reads in an email message from a path and instantiates it as a new Mail::Message
|
169
|
-
def
|
170
|
-
|
169
|
+
def self.read(filename)
|
170
|
+
self.new(File.read(filename))
|
171
171
|
end
|
172
|
-
|
172
|
+
|
173
173
|
# Delete all emails from a POP3 server.
|
174
174
|
# See Mail::POP3 for a complete documentation.
|
175
|
-
def
|
175
|
+
def self.delete_all(*args, &block)
|
176
176
|
retriever_method.delete_all(*args, &block)
|
177
177
|
end
|
178
|
-
|
179
|
-
|
178
|
+
|
179
|
+
# Instantiates a new Mail::Message using a string
|
180
|
+
def Mail.read_from_string(mail_as_string)
|
181
|
+
Mail.new(mail_as_string)
|
182
|
+
end
|
183
|
+
|
180
184
|
# Initialize the observers and interceptors arrays
|
181
185
|
@@delivery_notification_observers = []
|
182
186
|
@@delivery_interceptors = []
|
183
|
-
|
187
|
+
|
184
188
|
# You can register an object to be informed of every email that is sent through
|
185
189
|
# this method.
|
186
190
|
#
|
187
191
|
# Your object needs to respond to a single method #delivered_email(mail)
|
188
192
|
# which receives the email that is sent.
|
189
|
-
def
|
193
|
+
def self.register_observer(observer)
|
190
194
|
unless @@delivery_notification_observers.include?(observer)
|
191
195
|
@@delivery_notification_observers << observer
|
192
196
|
end
|
@@ -199,43 +203,43 @@ module Mail
|
|
199
203
|
# Your object needs to respond to a single method #delivering_email(mail)
|
200
204
|
# which receives the email that is about to be sent. Make your modifications
|
201
205
|
# directly to this object.
|
202
|
-
def
|
206
|
+
def self.register_interceptor(interceptor)
|
203
207
|
unless @@delivery_interceptors.include?(interceptor)
|
204
208
|
@@delivery_interceptors << interceptor
|
205
209
|
end
|
206
210
|
end
|
207
|
-
|
208
|
-
def
|
211
|
+
|
212
|
+
def self.inform_observers(mail)
|
209
213
|
@@delivery_notification_observers.each do |observer|
|
210
214
|
observer.delivered_email(mail)
|
211
215
|
end
|
212
216
|
end
|
213
|
-
|
214
|
-
def
|
217
|
+
|
218
|
+
def self.inform_interceptors(mail)
|
215
219
|
@@delivery_interceptors.each do |interceptor|
|
216
220
|
interceptor.delivering_email(mail)
|
217
221
|
end
|
218
222
|
end
|
219
223
|
|
220
224
|
protected
|
221
|
-
|
222
|
-
def
|
225
|
+
|
226
|
+
def self.random_tag
|
223
227
|
t = Time.now
|
224
228
|
sprintf('%x%x_%x%x%d%x',
|
225
229
|
t.to_i, t.tv_usec,
|
226
|
-
$$, Thread.current.object_id.abs,
|
230
|
+
$$, Thread.current.object_id.abs, self.uniq, rand(255))
|
227
231
|
end
|
228
|
-
|
232
|
+
|
229
233
|
private
|
230
234
|
|
231
|
-
def
|
235
|
+
def self.something_random
|
232
236
|
(Thread.current.object_id * rand(255) / Time.now.to_f).to_s.slice(-3..-1).to_i
|
233
237
|
end
|
234
|
-
|
235
|
-
def
|
238
|
+
|
239
|
+
def self.uniq
|
236
240
|
@@uniq += 1
|
237
241
|
end
|
238
|
-
|
239
|
-
@@uniq =
|
240
|
-
|
242
|
+
|
243
|
+
@@uniq = self.something_random
|
244
|
+
|
241
245
|
end
|