Rails - ActionMailer sometimes shows attachments before the email content?

后端 未结 3 1684
温柔的废话
温柔的废话 2021-01-13 01:54

How can I make it so ActionMailer always shows attachments at the bottom of the message: HTML, TXT, Attachments....

Problem is the attachment here is a text file:

3条回答
  •  暖寄归人
    2021-01-13 02:10

    this is rail 2.3 code (might be slightly different in rails3)

    just move you text part before attachment

    recipients  to@domain.com
    from      me@domain.com
    subject   "some subject"
    content_type  "multipart/mixed"
    
    part "text/plain" do |p|
      p.body = render_message 'my_message' #this is template file
    end
    
    attachment "application/octet-stream" do |a|
      a.body = File.read("some_file.jpg")
      a.filename = 'name.jpg'
    end
    

提交回复
热议问题