attachment sort order changes #616

Closed
landlord11 opened this Issue Aug 28, 2013 · 2 comments

Comments

Projects
None yet
3 participants

landlord11 commented Aug 28, 2013

I am running into some cases with attachments not being presented in the order I added them using the API. I noticed that Body offers a way to control part sorting, but it had no effect for me, because Message also sorts parts. However, Message has the sort list hardcoded. I'm hoping this patch is acceptable; it adds Message::set_sort_order to match Body::set_sort_order (and then I can disable sorting by passing in an empty array). Thanks.

--- /usr/pkg/lib/ruby/gems/1.9.3/gems/mail-2.5.4/lib/mail/message.rb    2013-07-06 20:09:05.774903777 -0500
+++ message.rb  2013-08-27 16:06:28.602124743 -0500
@@ -107,6 +107,7 @@
       @header = nil
       @charset = 'UTF-8'
       @defaulted_charset = true
-    @part_sort_order=[ "text/plain", "text/enriched", "text/html", "multipart/alternative" ]

  
     @smtp_envelope_from = nil
     @smtp_envelope_to = nil
  @@ -1776,11 +1777,18 @@
     self.body << text_part
   end
-    # Allows you to set the sort order of the parts, overriding the default sort order.
-    # Defaults to 'text/plain', then 'text/enriched', then 'text/html' with any other content
-    # type coming after.
-    def set_sort_order(order)
-      @part_sort_order = order
-    end
  +
   # Encodes the message, calls encode on all its parts, gets an email message
   # ready to send
   def ready_to_send!
     identify_and_set_transfer_encoding
-      parts.sort!([ "text/plain", "text/enriched", "text/html", "multipart/alternative" ])
-      parts.sort!(@part_sort_order)
     parts.each do |part|
       part.transport_encoding = transport_encoding
       part.ready_to_send!
Contributor

carsonreinke commented Sep 16, 2013

How about a PR instead?

Collaborator

jeremy commented May 17, 2017

Moving to current #1022

@jeremy jeremy closed this May 17, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment