Forum: Ruby on Rails Possible bug in ActionMailer (with patch)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7cafdbe9f20d97ff4c21340707018d51?d=identicon&s=25 Elan Feingold (elan)
on 2006-03-01 10:13
I wanted to write the following code, with emphasis on adding my own
headers to the second part with the :headers parameter.

class ArticleMailer < ActionMailer::Base
  def test_message
    subject         'This is a test'
    recipients      'elan@bluemandrill.com'
    from            'Exemplary Products <info@example.com>'
    content_type    'multipart/related'

    part :content_type => 'text/html',
         :body => 'Before <img src="cid:test@test.com"> After'

    part :content_type => 'image/png',
         :content_disposition => 'inline',
         :transfer_encoding => 'base64',
         :body => File.read("location.jpg"),
         :filename => 'location.jpg',
         :headers => { 'Content-ID' => '<test@test.com>' }
   end
end

Since ActionMailer::Part looks at params[:headers]. Unfortunately it
never seems to use them! I needed to add:

Index: action_mailer/part.rb
===================================================================
--- action_mailer/part.rb       (revision 3679)
+++ action_mailer/part.rb       (working copy)
@@ -96,7 +96,8 @@

         part.set_content_type(content_type, nil, { "charset" => charset
}) if content_type =~ /multipart/
       end

+      @headers.keys.each do |k| part[k] = @headers[k] end
       part
     end

Does this patch make sense? If not, what am I doing wrong? If so, who
would I submit it to?

Many thanks,

-elan
This topic is locked and can not be replied to.