开发者

Rails - Attachments for an email appear at the top of the email and not the bottom

Anyone know why rails, places attachments at the top of the email and not the bottom?

Mac Mail, and the Iphone for example show the attachments at the top of the email and not at the bottom, which is very strange.

My user_mailer.rb looks like this:

def error_email
    attachments['message.html'] = {:mime_type => 'text/html', :co开发者_Go百科ntent => message_text }

    mail(:to => @message_from, :subject => 'reason whyxxxx')
end

How can I get the attachment at the bottom of the email msg?

Thanks


I've run into this before. A quick fix is to do this in your mailer method to reverse the order of the email parts.

message = mail(:to => @message_from, :subject => 'reason whyxxxx')
message.parts.reverse!


You can sort the parts whichever way you want like this:

body.set_sort_order(order)
body.sort_parts!

-- where order defaults to ['text/plain', 'text/enriched', 'text/html', 'multipart/alternative'].

However this sorts on content type, as far as I can tell, so if your attachment has the same content type as the text part it won't make any difference.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜