actionmailer 3.0.0.rc → 3.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionmailer might be problematic. Click here for more details.

data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ *Rails 3.0.0 [release candidate 2] (August 23rd, 2010)*
2
+
3
+ * No material changes (see http://github.com/rails/rails/compare/v3.0.0_RC...v3.0.0_RC2 for gory details)
4
+
5
+
1
6
  *Rails 3.0.0 [release candidate] (July 26th, 2010)*
2
7
 
3
8
  * No material changes
@@ -181,7 +186,7 @@
181
186
 
182
187
  * ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, Marcel Molina Jr.]
183
188
 
184
- * Replace alias method chaining with Module#alias_method_chain. [Marcel Molina Jr.]
189
+ * Replace alias method chaining with Module#alias_method_chain. [Marcel Molina Jr.]
185
190
 
186
191
  * Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.]
187
192
 
@@ -327,7 +332,7 @@
327
332
 
328
333
  * Added that deliver_* will now return the email that was sent
329
334
 
330
- * Added that quoting to UTF-8 only happens if the characters used are in that range #955 [Jamis Buck]
335
+ * Added that quoting to UTF-8 only happens if the characters used are in that range #955 [Jamis Buck]
331
336
 
332
337
  * Fixed quoting for all address headers, not just to #955 [Jamis Buck]
333
338
 
@@ -366,7 +371,7 @@
366
371
  @body = "Nothing to see here."
367
372
  @charset = "iso-8859-1"
368
373
  end
369
-
374
+
370
375
  def unencoded_subject(recipient)
371
376
  @recipients = recipient
372
377
  @subject = "testing unencoded subject"
@@ -375,7 +380,7 @@
375
380
  @encode_subject = false
376
381
  @charset = "iso-8859-1"
377
382
  end
378
-
383
+
379
384
 
380
385
  *0.6.1* (January 18th, 2005)
381
386
 
@@ -5,7 +5,7 @@ are used to consolidate code for sending out forgotten passwords, welcome
5
5
  wishes on signup, invoices for billing, and any other use case that requires
6
6
  a written notification to either a person or another system.
7
7
 
8
- Action Mailer is in essence a wrapper around Action Controller and the
8
+ Action Mailer is in essence a wrapper around Action Controller and the
9
9
  Mail gem. It provides a way to make emails using templates in the same
10
10
  way that Action Controller renders views using templates.
11
11
 
@@ -23,7 +23,7 @@ This can be as simple as:
23
23
 
24
24
  class Notifier < ActionMailer::Base
25
25
  delivers_from 'system@loudthinking.com'
26
-
26
+
27
27
  def welcome(recipient)
28
28
  @recipient = recipient
29
29
  mail(:to => recipient,
@@ -36,13 +36,13 @@ ERb) that has the instance variables that are declared in the mailer action.
36
36
 
37
37
  So the corresponding body template for the method above could look like this:
38
38
 
39
- Hello there,
39
+ Hello there,
40
40
 
41
41
  Mr. <%= @recipient %>
42
42
 
43
43
  Thank you for signing up!
44
-
45
- And if the recipient was given as "david@loudthinking.com", the email
44
+
45
+ And if the recipient was given as "david@loudthinking.com", the email
46
46
  generated would look like this:
47
47
 
48
48
  Date: Mon, 25 Jan 2010 22:48:09 +1100
@@ -55,7 +55,7 @@ generated would look like this:
55
55
  charset="US-ASCII";
56
56
  Content-Transfer-Encoding: 7bit
57
57
 
58
- Hello there,
58
+ Hello there,
59
59
 
60
60
  Mr. david@loudthinking.com
61
61
 
@@ -65,8 +65,8 @@ simply call the method and optionally call +deliver+ on the return value.
65
65
 
66
66
  Calling the method returns a Mail Message object:
67
67
 
68
- message = Notifier.welcome #=> Returns a Mail::Message object
69
- message.deliver #=> delivers the email
68
+ message = Notifier.welcome # => Returns a Mail::Message object
69
+ message.deliver # => delivers the email
70
70
 
71
71
  Or you can just chain the methods together like:
72
72
 
@@ -74,9 +74,9 @@ Or you can just chain the methods together like:
74
74
 
75
75
  == Receiving emails
76
76
 
77
- To receive emails, you need to implement a public instance method called receive that takes a
78
- tmail object as its single parameter. The Action Mailer framework has a corresponding class method,
79
- which is also called receive, that accepts a raw, unprocessed email as a string, which it then turns
77
+ To receive emails, you need to implement a public instance method called <tt>receive</tt> that takes a
78
+ tmail object as its single parameter. The Action Mailer framework has a corresponding class method,
79
+ which is also called <tt>receive</tt>, that accepts a raw, unprocessed email as a string, which it then turns
80
80
  into the tmail object and calls the receive instance method.
81
81
 
82
82
  Example:
@@ -90,7 +90,7 @@ Example:
90
90
 
91
91
  if email.has_attachments?
92
92
  for attachment in email.attachments
93
- page.attachments.create({
93
+ page.attachments.create({
94
94
  :file => attachment, :description => email.subject
95
95
  })
96
96
  end
@@ -98,13 +98,13 @@ Example:
98
98
  end
99
99
  end
100
100
 
101
- This Mailman can be the target for Postfix or other MTAs. In Rails, you would use the runner in the
101
+ This Mailman can be the target for Postfix or other MTAs. In Rails, you would use the runner in the
102
102
  trivial case like this:
103
103
 
104
104
  rails runner 'Mailman.receive(STDIN.read)'
105
105
 
106
- However, invoking Rails in the runner for each mail to be received is very resource intensive. A single
107
- instance of Rails should be run within a daemon if it is going to be utilized to process more than just
106
+ However, invoking Rails in the runner for each mail to be received is very resource intensive. A single
107
+ instance of Rails should be run within a daemon if it is going to be utilized to process more than just
108
108
  a limited number of email.
109
109
 
110
110
  == Configuration
@@ -41,16 +41,16 @@ module ActionMailer #:nodoc:
41
41
  # in the same manner as <tt>attachments[]=</tt>
42
42
  #
43
43
  # * <tt>headers[]=</tt> - Allows you to specify any header field in your email such
44
- # as <tt>headers['X-No-Spam'] = 'True'</tt>. Note, while most fields (like <tt>To:</tt>
44
+ # as <tt>headers['X-No-Spam'] = 'True'</tt>. Note, while most fields like <tt>To:</tt>
45
45
  # <tt>From:</tt> can only appear once in an email header, other fields like <tt>X-Anything</tt>
46
46
  # can appear multiple times. If you want to change a field that can appear multiple times,
47
- # you need to set it to nil first so that Mail knows you are replacing it, not adding
48
- # another field of the same name.)
47
+ # you need to set it to nil first so that Mail knows you are replacing it and not adding
48
+ # another field of the same name.
49
49
  #
50
50
  # * <tt>headers(hash)</tt> - Allows you to specify multiple headers in your email such
51
51
  # as <tt>headers({'X-No-Spam' => 'True', 'In-Reply-To' => '1234@message.id'})</tt>
52
52
  #
53
- # * <tt>mail</tt> - Allows you to specify your email to send.
53
+ # * <tt>mail</tt> - Allows you to specify email to be sent.
54
54
  #
55
55
  # The hash passed to the mail method allows you to specify any header that a Mail::Message
56
56
  # will accept (any valid Email header including optional fields).
@@ -66,7 +66,7 @@ module ActionMailer #:nodoc:
66
66
  # format.html
67
67
  # end
68
68
  #
69
- # The block syntax is useful if also need to specify information specific to a part:
69
+ # The block syntax is also useful in providing information specific to a part:
70
70
  #
71
71
  # mail(:to => user.email) do |format|
72
72
  # format.text(:content_transfer_encoding => "base64")
@@ -121,7 +121,7 @@ module ActionMailer #:nodoc:
121
121
  #
122
122
  # <%= users_url(:host => "example.com") %>
123
123
  #
124
- # You will want to avoid using the <tt>name_of_route_path</tt> form of named routes because it doesn't
124
+ # You want to avoid using the <tt>name_of_route_path</tt> form of named routes because it doesn't
125
125
  # make sense to generate relative URLs in email messages.
126
126
  #
127
127
  # It is also possible to set a default host that will be used in all mailers by setting the <tt>:host</tt>
@@ -132,7 +132,7 @@ module ActionMailer #:nodoc:
132
132
  # Setting <tt>ActionMailer::Base.default_url_options</tt> directly is now deprecated, use the configuration
133
133
  # option mentioned above to set the default host.
134
134
  #
135
- # If you do decide to set a default <tt>:host</tt> for your mailers you will want to use the
135
+ # If you do decide to set a default <tt>:host</tt> for your mailers you want to use the
136
136
  # <tt>:only_path => false</tt> option when using <tt>url_for</tt>. This will ensure that absolute URLs are
137
137
  # generated because the <tt>url_for</tt> view helper will, by default, generate relative URLs when a
138
138
  # <tt>:host</tt> option isn't explicitly provided.
@@ -154,7 +154,7 @@ module ActionMailer #:nodoc:
154
154
  # detect and use multipart templates, where each template is named after the name of the action, followed
155
155
  # by the content type. Each such detected template will be added as separate part to the message.
156
156
  #
157
- # For example, if the following templates existed:
157
+ # For example, if the following templates exist:
158
158
  # * signup_notification.text.plain.erb
159
159
  # * signup_notification.text.html.erb
160
160
  # * signup_notification.text.xml.builder
@@ -171,8 +171,7 @@ module ActionMailer #:nodoc:
171
171
  #
172
172
  # = Attachments
173
173
  #
174
- # You can see above how to make a multipart HTML / Text email, to send attachments is just
175
- # as easy:
174
+ # Sending attachment in emails is easy:
176
175
  #
177
176
  # class ApplicationMailer < ActionMailer::Base
178
177
  # def welcome(recipient)
@@ -188,33 +187,31 @@ module ActionMailer #:nodoc:
188
187
  # with the filename +free_book.pdf+.
189
188
  #
190
189
  # = Inline Attachments
191
- #
192
- # You can also specify that a file should be displayed inline with other HTML. For example a
193
- # corporate logo or a photo or the like.
194
- #
195
- # To do this is simple, in the Mailer:
196
- #
190
+ #
191
+ # You can also specify that a file should be displayed inline with other HTML. This is useful
192
+ # if you want to display a corporate logo or a photo.
193
+ #
197
194
  # class ApplicationMailer < ActionMailer::Base
198
195
  # def welcome(recipient)
199
196
  # attachments.inline['photo.png'] = File.read('path/to/photo.png')
200
197
  # mail(:to => recipient, :subject => "Here is what we look like")
201
198
  # end
202
199
  # end
203
- #
200
+ #
204
201
  # And then to reference the image in the view, you create a <tt>welcome.html.erb</tt> file and
205
- # make a call to +image_tag+ passing in the attachment you want to display and then call
202
+ # make a call to +image_tag+ passing in the attachment you want to display and then call
206
203
  # +url+ on the attachment to get the relative content id path for the image source:
207
- #
204
+ #
208
205
  # <h1>Please Don't Cringe</h1>
209
- #
206
+ #
210
207
  # <%= image_tag attachments['photo.png'].url -%>
211
- #
208
+ #
212
209
  # As we are using Action View's +image_tag+ method, you can pass in any other options you want:
213
- #
210
+ #
214
211
  # <h1>Please Don't Cringe</h1>
215
- #
212
+ #
216
213
  # <%= image_tag attachments['photo.png'].url, :alt => 'Our Photo', :class => 'photo' -%>
217
- #
214
+ #
218
215
  # = Observing and Intercepting Mails
219
216
  #
220
217
  # Action Mailer provides hooks into the Mail observer and interceptor methods. These allow you to
@@ -449,6 +446,33 @@ module ActionMailer #:nodoc:
449
446
  super
450
447
  end
451
448
 
449
+ class DeprecatedHeaderProxy < ActiveSupport::BasicObject
450
+ def initialize(message)
451
+ @message = message
452
+ end
453
+
454
+ def []=(key, value)
455
+ unless value.is_a?(::String)
456
+ ::ActiveSupport::Deprecation.warn("Using a non-String object for a header's value is deprecated. " \
457
+ "You specified #{value.inspect} (a #{value.class}) for #{key}", caller)
458
+
459
+ value = value.to_s
460
+ end
461
+
462
+ @message[key] = value
463
+ end
464
+
465
+ def headers(hash = {})
466
+ hash.each_pair do |k,v|
467
+ self[k] = v
468
+ end
469
+ end
470
+
471
+ def method_missing(meth, *args, &block)
472
+ @message.send(meth, *args, &block)
473
+ end
474
+ end
475
+
452
476
  # Allows you to pass random and unusual headers to the new +Mail::Message+ object
453
477
  # which will add them to itself.
454
478
  #
@@ -465,9 +489,9 @@ module ActionMailer #:nodoc:
465
489
  # X-Special-Domain-Specific-Header: SecretValue
466
490
  def headers(args=nil)
467
491
  if args
468
- @_message.headers(args)
492
+ DeprecatedHeaderProxy.new(@_message).headers(args)
469
493
  else
470
- @_message
494
+ DeprecatedHeaderProxy.new(@_message)
471
495
  end
472
496
  end
473
497
 
@@ -496,10 +520,10 @@ module ActionMailer #:nodoc:
496
520
  # You can also search for specific attachments:
497
521
  #
498
522
  # # By Filename
499
- # mail.attachments['filename.jpg'] #=> Mail::Part object or nil
523
+ # mail.attachments['filename.jpg'] # => Mail::Part object or nil
500
524
  #
501
525
  # # or by index
502
- # mail.attachments[0] #=> Mail::Part (first attachment)
526
+ # mail.attachments[0] # => Mail::Part (first attachment)
503
527
  #
504
528
  def attachments
505
529
  @_message.attachments
@@ -46,11 +46,11 @@ module ActionMailer
46
46
  # as alias and the default options supplied:
47
47
  #
48
48
  # Example:
49
- #
49
+ #
50
50
  # add_delivery_method :sendmail, Mail::Sendmail,
51
51
  # :location => '/usr/sbin/sendmail',
52
52
  # :arguments => '-i -t'
53
- #
53
+ #
54
54
  def add_delivery_method(symbol, klass, default_options={})
55
55
  class_attribute(:"#{symbol}_settings") unless respond_to?(:"#{symbol}_settings")
56
56
  send(:"#{symbol}_settings=", default_options)
@@ -1,3 +1,5 @@
1
+ require 'active_support/core_ext/object/try'
2
+
1
3
  module ActionMailer
2
4
  # This is the API which is deprecated and is going to be removed on Rails 3.1 release.
3
5
  # Part of the old API will be deprecated after 3.1, for a smoother deprecation process.
@@ -94,6 +96,12 @@ module ActionMailer
94
96
  def render(*args)
95
97
  options = args.last.is_a?(Hash) ? args.last : {}
96
98
 
99
+ if file = options[:file] and !file.index("/")
100
+ ActiveSupport::Deprecation.warn("render :file is deprecated except for absolute paths. " \
101
+ "Please use render :template instead")
102
+ options[:prefix] = _prefix
103
+ end
104
+
97
105
  if options[:body].is_a?(Hash)
98
106
  ActiveSupport::Deprecation.warn(':body in render deprecated. Please use instance ' <<
99
107
  'variables as assigns instead', caller[0,1])
@@ -15,11 +15,11 @@ module ActionMailer
15
15
  :columns => 72, :first_indent => 2, :body_indent => 2, :text => paragraph
16
16
  ).format
17
17
  }.join("\n")
18
-
18
+
19
19
  # Make list points stand on their own line
20
20
  formatted.gsub!(/[ ]*([*]+) ([^*]*)/) { |s| " #{$1} #{$2.strip}\n" }
21
21
  formatted.gsub!(/[ ]*([#]+) ([^#]*)/) { |s| " #{$1} #{$2.strip}\n" }
22
-
22
+
23
23
  formatted
24
24
  end
25
25
 
@@ -116,36 +116,36 @@ module ActionMailer
116
116
 
117
117
  def normalize_nonfile_hash(params)
118
118
  content_disposition = "attachment;"
119
-
119
+
120
120
  mime_type = params.delete(:mime_type)
121
-
121
+
122
122
  if content_type = params.delete(:content_type)
123
123
  content_type = "#{mime_type || content_type};"
124
124
  end
125
125
 
126
126
  params[:body] = params.delete(:data) if params[:data]
127
-
127
+
128
128
  { :content_type => content_type,
129
129
  :content_disposition => content_disposition }.merge(params)
130
130
  end
131
-
131
+
132
132
  def normalize_file_hash(params)
133
133
  filename = File.basename(params.delete(:filename))
134
134
  content_disposition = "attachment; filename=\"#{File.basename(filename)}\""
135
-
135
+
136
136
  mime_type = params.delete(:mime_type)
137
-
137
+
138
138
  if (content_type = params.delete(:content_type)) && (content_type !~ /filename=/)
139
139
  content_type = "#{mime_type || content_type}; filename=\"#{filename}\""
140
140
  end
141
-
141
+
142
142
  params[:body] = params.delete(:data) if params[:data]
143
-
143
+
144
144
  { :content_type => content_type,
145
145
  :content_disposition => content_disposition }.merge(params)
146
146
  end
147
147
 
148
- def create_mail
148
+ def create_mail
149
149
  m = @_message
150
150
 
151
151
  set_fields!({:subject => subject, :to => recipients, :from => from,
@@ -178,14 +178,14 @@ module ActionMailer
178
178
 
179
179
  wrap_delivery_behavior!
180
180
  m.content_transfer_encoding = '8bit' unless m.body.only_us_ascii?
181
-
181
+
182
182
  @_message
183
183
  end
184
-
184
+
185
185
  # Set up the default values for the various instance variables of this
186
186
  # mailer. Subclasses may override this method to provide different
187
187
  # defaults.
188
- def initialize_defaults(method_name)
188
+ def initialize_defaults(method_name)
189
189
  @charset ||= self.class.default[:charset].try(:dup)
190
190
  @content_type ||= self.class.default[:content_type].try(:dup)
191
191
  @implicit_parts_order ||= self.class.default[:parts_order].try(:dup)
@@ -201,7 +201,7 @@ module ActionMailer
201
201
  @body ||= {}
202
202
  end
203
203
 
204
- def create_parts
204
+ def create_parts
205
205
  if String === @body
206
206
  @parts.unshift create_inline_part(@body)
207
207
  elsif @parts.empty? || @parts.all? { |p| p.content_disposition =~ /^attachment/ }
@@ -220,7 +220,7 @@ module ActionMailer
220
220
  end
221
221
  end
222
222
 
223
- def create_inline_part(body, mime_type=nil)
223
+ def create_inline_part(body, mime_type=nil)
224
224
  ct = mime_type || "text/plain"
225
225
  main_type, sub_type = split_content_type(ct.to_s)
226
226
 
@@ -242,11 +242,11 @@ module ActionMailer
242
242
  m.reply_to ||= headers.delete(:reply_to) if headers[:reply_to]
243
243
  end
244
244
 
245
- def split_content_type(ct)
245
+ def split_content_type(ct)
246
246
  ct.to_s.split("/")
247
247
  end
248
248
 
249
- def parse_content_type(defaults=nil)
249
+ def parse_content_type(defaults=nil)
250
250
  if @content_type.blank?
251
251
  [ nil, {} ]
252
252
  else
@@ -1,12 +1,12 @@
1
1
  module Mail
2
2
  class Message
3
-
3
+
4
4
  def set_content_type(*args)
5
5
  ActiveSupport::Deprecation.warn('Message#set_content_type is deprecated, please just call ' <<
6
6
  'Message#content_type with the same arguments', caller[0,2])
7
7
  content_type(*args)
8
8
  end
9
-
9
+
10
10
  alias :old_transfer_encoding :transfer_encoding
11
11
  def transfer_encoding(value = nil)
12
12
  if value
@@ -29,6 +29,6 @@ module Mail
29
29
  'please call Message#filename', caller[0,2])
30
30
  filename
31
31
  end
32
-
32
+
33
33
  end
34
34
  end
@@ -3,7 +3,7 @@ module ActionMailer
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
5
  TINY = 0
6
- BUILD = "rc"
6
+ BUILD = "rc2"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionmailer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7712042
4
+ hash: 977940607
5
5
  prerelease: true
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
9
  - 0
10
- - rc
11
- version: 3.0.0.rc
10
+ - rc2
11
+ version: 3.0.0.rc2
12
12
  platform: ruby
13
13
  authors:
14
14
  - David Heinemeier Hansson
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-07-26 00:00:00 -05:00
19
+ date: 2010-08-23 00:00:00 -05:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -27,13 +27,13 @@ dependencies:
27
27
  requirements:
28
28
  - - "="
29
29
  - !ruby/object:Gem::Version
30
- hash: 7712042
30
+ hash: 977940607
31
31
  segments:
32
32
  - 3
33
33
  - 0
34
34
  - 0
35
- - rc
36
- version: 3.0.0.rc
35
+ - rc2
36
+ version: 3.0.0.rc2
37
37
  type: :runtime
38
38
  version_requirements: *id001
39
39
  - !ruby/object:Gem::Dependency