aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/lib
diff options
context:
space:
mode:
authorMikel Lindsaar <raasdnil@gmail.com>2009-12-28 12:25:14 +1100
committerMikel Lindsaar <raasdnil@gmail.com>2009-12-28 12:25:14 +1100
commitc039bcdb1c94d8b28fc9398d4b88b4453cdd9fb1 (patch)
tree7caa22e23908e2eec037c81633ed0a64df45b651 /actionmailer/lib
parent971f4ff829f7ead6381e0fead93b33104b037cdd (diff)
downloadrails-c039bcdb1c94d8b28fc9398d4b88b4453cdd9fb1.tar.gz
rails-c039bcdb1c94d8b28fc9398d4b88b4453cdd9fb1.tar.bz2
rails-c039bcdb1c94d8b28fc9398d4b88b4453cdd9fb1.zip
Moved sort_parts into Mail, updated mail requirement to 1.4.2
Diffstat (limited to 'actionmailer/lib')
-rw-r--r--actionmailer/lib/action_mailer.rb3
-rw-r--r--actionmailer/lib/action_mailer/base.rb41
2 files changed, 12 insertions, 32 deletions
diff --git a/actionmailer/lib/action_mailer.rb b/actionmailer/lib/action_mailer.rb
index 0221e36bb0..8ac6318f9e 100644
--- a/actionmailer/lib/action_mailer.rb
+++ b/actionmailer/lib/action_mailer.rb
@@ -24,6 +24,7 @@
actionpack_path = File.expand_path('../../../actionpack/lib', __FILE__)
$:.unshift(actionpack_path) if File.directory?(actionpack_path) && !$:.include?(actionpack_path)
+
require 'action_controller'
require 'action_view'
@@ -46,4 +47,4 @@ module Text
autoload :Format, 'action_mailer/vendor/text_format'
end
-require 'mail' \ No newline at end of file
+require 'mail'
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index f28bce9947..ba9ec3b4de 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -282,7 +282,13 @@ module ActionMailer #:nodoc:
@@default_mime_version = "1.0"
cattr_accessor :default_mime_version
- @@default_implicit_parts_order = [ "text/html", "text/enriched", "text/plain" ]
+ # This specifies the order that the parts of a multipart email will be. Usually you put
+ # text/plain at the top so someone without a MIME capable email reader can read the plain
+ # text of your email first.
+ #
+ # Any content type that is not listed here will be inserted in the order you add them to
+ # the email after the content types you list here.
+ @@default_implicit_parts_order = [ "text/plain", "text/enriched", "text/html" ]
cattr_accessor :default_implicit_parts_order
@@protected_instance_variables = %w(@parts @mail)
@@ -534,7 +540,6 @@ module ActionMailer #:nodoc:
if @parts.size > 1
@content_type = "multipart/alternative" if @content_type !~ /^multipart/
- @parts = sort_parts(@parts, @implicit_parts_order)
end
# If this is a multipart e-mail add the mime_version if it is not
@@ -554,35 +559,6 @@ module ActionMailer #:nodoc:
)
end
- def sort_parts(parts, order = []) #:nodoc:
- order = order.collect { |s| s.downcase }
-
- parts = parts.sort do |a, b|
- a_ct = a.content_type.string.downcase
- b_ct = b.content_type.string.downcase
-
- a_in = order.include? a_ct
- b_in = order.include? b_ct
-
- s = case
- when a_in && b_in
- order.index(a_ct) <=> order.index(b_ct)
- when a_in
- -1
- when b_in
- 1
- else
- a_ct <=> b_ct
- end
-
- # reverse the ordering because parts that come last are displayed
- # first in mail clients
- (s * -1)
- end
-
- parts
- end
-
def create_mail #:nodoc:
m = Mail.new
@@ -606,9 +582,12 @@ module ActionMailer #:nodoc:
m.content_type([main_type, sub_type, ctype_attrs])
m.body = @parts.first.body.encoded
else
+
@parts.each do |p|
m.add_part(p)
end
+ m.body.set_sort_order(@implicit_parts_order)
+ m.body.sort_parts!
if real_content_type =~ /multipart/
ctype_attrs.delete "charset"