Home Play Pinja Bobbity flop

A blog about Ruby, Rails and other Tech. Mostly.

Back to blog

28th Jan 2006, 9:07pm
Inline images from Actionmailer

Rails has a nice email component, useful for simple stuff. But for more complicated multipart emails it's, well, not so useful - at least as it comes out of the box.

I wanted to send HTML emails with inline images. Simple enough, but the attached images need to be identified correctly.

There is a patch for rails to make this work, but it did not fully work for me. In particular, the content-id for each image was being thrown away.

I editied /usr/local/lib/ruby/gems/1.8/gems/actionmailer-1.1.5/lib/action_mailer/vendor/tmail/header.rb to fix it:

      'content-disposition'       => ContentDispositionHeader,
#      'content-id'                => MessageIdHeader,
      'subject'                   => UnstructuredHeader,

Commenting out the content-id line in this file makes things work ok.

Also, don't forget to set the right content-type in your ActionMailer subclass:

content_type "multipart/related"

Back to blog