diff options
author | José Valim and Mikel Lindsaar <pair@programming.com> | 2010-01-26 01:51:23 +0100 |
---|---|---|
committer | José Valim and Mikel Lindsaar <pair@programming.com> | 2010-01-26 01:51:23 +0100 |
commit | 4af2bbc6b446726b7174d06b5bffbaba82906cbb (patch) | |
tree | 08981544e55ec1b709226e914942d01fa99adda2 /actionmailer/lib/action_mailer | |
parent | 6589976533b7a6850390ed5d6526ca719e56c5ca (diff) | |
parent | 74a5889abef1212d373ea994f1c93daedee8932c (diff) | |
download | rails-4af2bbc6b446726b7174d06b5bffbaba82906cbb.tar.gz rails-4af2bbc6b446726b7174d06b5bffbaba82906cbb.tar.bz2 rails-4af2bbc6b446726b7174d06b5bffbaba82906cbb.zip |
Merge branch 'master' of github.com:mikel/rails
Diffstat (limited to 'actionmailer/lib/action_mailer')
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 65d1ba47d9..44df30b1ba 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -50,7 +50,7 @@ module ActionMailer #:nodoc: # # The mail method, if not passed a block, will inspect your views and send all the views with # the same name as the method, so the above action would send the +welcome.plain.erb+ view file - # as well as the +welcome.html.erb+ view file in a +multipart/alternate+ email. + # as well as the +welcome.html.erb+ view file in a +multipart/alternative+ email. # # If you want to explicitly render only certain templates, pass a block: # @@ -177,7 +177,7 @@ module ActionMailer #:nodoc: # # Which will (if it had both a <tt>.text.erb</tt> and <tt>.html.erb</tt> tempalte in the view # directory), send a complete <tt>multipart/mixed</tt> email with two parts, the first part being - # a <tt>multipart/alternate</tt> with the text and HTML email parts inside, and the second being + # a <tt>multipart/alternative</tt> with the text and HTML email parts inside, and the second being # a <tt>application/pdf</tt> with a Base64 encoded copy of the file.pdf book with the filename # +free_book.pdf+. # @@ -456,7 +456,7 @@ module ActionMailer #:nodoc: # format.html { render :text => "<h1>Hello Mikel!</h1>" } # end # - # Which will render a <tt>multipart/alternate</tt> email with <tt>text/plain</tt> and + # Which will render a <tt>multipart/alternative</tt> email with <tt>text/plain</tt> and # <tt>text/html</tt> parts. # # The block syntax also allows you to customize the part headers if desired: @@ -484,10 +484,11 @@ module ActionMailer #:nodoc: # Render the templates and blocks responses, sort_order = collect_responses_and_sort_order(headers, &block) - content_type ||= create_parts_from_responses(m, responses, charset) + + create_parts_from_responses(m, responses, charset) # Tidy up content type, charset, mime version and sort order - m.content_type = content_type + m.content_type = set_content_type(m, content_type) m.charset = charset m.mime_version = mime_version sort_order = headers[:parts_order] || sort_order || self.class.default_implicit_parts_order.dup @@ -504,6 +505,20 @@ module ActionMailer #:nodoc: protected + def set_content_type(m, user_content_type) + params = m.content_type_parameters || {} + case + when user_content_type.present? + user_content_type + when m.has_attachments? + ["multipart", "mixed", params] + when m.multipart? + ["multipart", "alternative", params] + else + self.class.default_content_type.dup + end + end + def default_subject #:nodoc: mailer_scope = self.class.mailer_name.gsub('/', '.') I18n.t(:subject, :scope => [:actionmailer, mailer_scope, action_name], :default => action_name.humanize) @@ -563,16 +578,14 @@ module ActionMailer #:nodoc: headers = responses[0] headers.each { |k,v| m[k] = v } return responses[0][:content_type] - elsif responses.size > 1 && m.has_attachments? + elsif responses.size > 1 && m.has_attachments? container = Mail::Part.new - container.content_type = "multipart/alternate" + container.content_type = "multipart/alternative" responses.each { |r| insert_part(container, r, charset) } m.add_part(container) else responses.each { |r| insert_part(m, r, charset) } end - - m.has_attachments? ? "multipart/mixed" : "multipart/alternate" end def insert_part(container, response, charset) #:nodoc: |