mail 2.0.3 → 2.0.5
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 +12 -0
- data/Rakefile +1 -1
- data/lib/mail/mail.rb +15 -1
- data/lib/mail/message.rb +30 -3
- data/lib/mail/network/delivery_methods/test_mailer.rb +5 -7
- data/lib/mail/version.rb +1 -1
- metadata +2 -2
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
== Sat Jan 23 23:49:50 UTC 2010 Mikel Lindsaar <raasdnil@gmail.com>
|
2
|
+
|
3
|
+
* Version bump to 2.0.5
|
4
|
+
* Added :raise_delivery_errors to Mail::Message, if set to false will silently rescue all errors raised by the delivery methods, set to true by default
|
5
|
+
|
6
|
+
== Sat Jan 23 23:28:42 UTC 2010 Mikel Lindsaar <raasdnil@gmail.com>
|
7
|
+
|
8
|
+
* Version bump to 2.0.4
|
9
|
+
* Added :perform_deliveries to mail, will not actually call deliver on the delivery method if this is set to false, set to true by default.
|
10
|
+
* Added @delivery_notification_observers to mail messages, you can register an observer with mail by calling mail.register_for_delivery_notification(observer) and then when mail is told to :deliver it will call your observer with observer.delivered_email(self). It will call your observer if it actually performed the delivery or not (that is, irregardless of the :perform_deliveries flag)
|
11
|
+
* Added ability to overwrite the Mail.deliveries store with an object of your choice instead of just an array, this is a good way to find out if something actually got delivered as if :perform_deliveries is false, this collection will not get the mail message appended
|
12
|
+
|
1
13
|
== Sat Jan 23 05:32:53 UTC 2010 Mikel Lindsaar <raasdnil@gmail.com>
|
2
14
|
|
3
15
|
* Version bump to 2.0.3
|
data/Rakefile
CHANGED
data/lib/mail/mail.rb
CHANGED
@@ -137,7 +137,7 @@ module Mail
|
|
137
137
|
# And your email object will be created and sent.
|
138
138
|
def Mail.deliver(*args, &block)
|
139
139
|
mail = Mail.new(args, &block)
|
140
|
-
|
140
|
+
mail.deliver
|
141
141
|
mail
|
142
142
|
end
|
143
143
|
|
@@ -174,6 +174,20 @@ module Mail
|
|
174
174
|
def Mail.deliveries
|
175
175
|
@@deliveries ||= []
|
176
176
|
end
|
177
|
+
|
178
|
+
# Allows you to over write the default deliveries store from an array to some
|
179
|
+
# other object. If you just want to clear the store, call Mail.deliveries.clear.
|
180
|
+
#
|
181
|
+
# If you place another object here, please make sure it responds to:
|
182
|
+
#
|
183
|
+
# * << (message)
|
184
|
+
# * clear
|
185
|
+
# * length
|
186
|
+
# * size
|
187
|
+
# * and other common Array methods
|
188
|
+
def Mail.deliveries=(val)
|
189
|
+
@@deliveries = val
|
190
|
+
end
|
177
191
|
|
178
192
|
protected
|
179
193
|
|
data/lib/mail/message.rb
CHANGED
@@ -99,8 +99,11 @@ module Mail
|
|
99
99
|
@body = nil
|
100
100
|
@text_part = nil
|
101
101
|
@html_part = nil
|
102
|
-
|
103
|
-
@
|
102
|
+
|
103
|
+
@perform_deliveries = true
|
104
|
+
@raise_delivery_errors = true
|
105
|
+
@delivery_method = Mail.delivery_method.dup
|
106
|
+
@delivery_notification_observers = []
|
104
107
|
|
105
108
|
if args.flatten.first.respond_to?(:each_pair)
|
106
109
|
init_with_hash(args.flatten.first)
|
@@ -114,6 +117,21 @@ module Mail
|
|
114
117
|
|
115
118
|
self
|
116
119
|
end
|
120
|
+
|
121
|
+
attr_accessor :perform_deliveries
|
122
|
+
attr_accessor :raise_delivery_errors
|
123
|
+
|
124
|
+
def register_for_delivery_notification(observer)
|
125
|
+
unless @delivery_notification_observers.include?(observer)
|
126
|
+
@delivery_notification_observers << observer
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def inform_observers
|
131
|
+
@delivery_notification_observers.each do |observer|
|
132
|
+
observer.delivered_email(self)
|
133
|
+
end
|
134
|
+
end
|
117
135
|
|
118
136
|
# Delivers an mail object.
|
119
137
|
#
|
@@ -122,7 +140,16 @@ module Mail
|
|
122
140
|
# mail = Mail.read('file.eml')
|
123
141
|
# mail.deliver!
|
124
142
|
def deliver
|
125
|
-
|
143
|
+
if perform_deliveries
|
144
|
+
begin
|
145
|
+
delivery_method.deliver!(self)
|
146
|
+
Mail.deliveries << self
|
147
|
+
rescue Exception => e # Net::SMTP errors or sendmail pipe errors
|
148
|
+
raise e if raise_delivery_errors
|
149
|
+
end
|
150
|
+
end
|
151
|
+
inform_observers
|
152
|
+
self
|
126
153
|
end
|
127
154
|
|
128
155
|
alias :deliver! :deliver
|
@@ -1,4 +1,9 @@
|
|
1
1
|
module Mail
|
2
|
+
# The TestMailer is a bare bones mailer that does nothing. It is useful
|
3
|
+
# when you are testing.
|
4
|
+
#
|
5
|
+
# It also provides a template of the minimum methods you require to implement
|
6
|
+
# if you want to make a custom mailer for Mail
|
2
7
|
class TestMailer
|
3
8
|
|
4
9
|
def initialize(values)
|
@@ -7,14 +12,7 @@ module Mail
|
|
7
12
|
|
8
13
|
attr_accessor :settings
|
9
14
|
|
10
|
-
# The Test Mailer provides a mail delivery method that does not hit
|
11
|
-
# your network or mail agent, in this way you can send all the emails
|
12
|
-
# you want and they will just be appended to Mail.deliveries
|
13
|
-
#
|
14
|
-
# See the README under Using Mail with Testing or Spec'ing Libraries
|
15
|
-
# for more information.
|
16
15
|
def deliver!(mail)
|
17
|
-
Mail.deliveries << mail
|
18
16
|
end
|
19
17
|
|
20
18
|
end
|
data/lib/mail/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Lindsaar
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-24 00:00:00 +11:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|