GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
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
- # 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
# Encodes the message, calls encode on all its parts, gets an email message
# ready to send
- parts.sort!([ "text/plain", "text/enriched", "text/html", "multipart/alternative" ])
parts.each do |part|
part.transport_encoding = transport_encoding
How about a PR instead?
Moving to current #1022