Possible bug in ActionMailer (with patch)


#1

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 ‘removed_email_address@domain.invalid’
from ‘Exemplary P. removed_email_address@domain.invalid
content_type ‘multipart/related’

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

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

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