About ActionMailer, Content-Type and Hell
Ruby on Rails is a very nice web development platform and generally using is very smooth. However, there are rough edges and today I discovered one of the least pleasant ones: Embedding images in HTML.
Generally, what you want to do is to create a multipart email with attached emails and then reference those emails in the HTML source code. You have to set the Content-Id header of the Image MIME part - say to - and then you can reference this image with <img src="cid:image1" />.
However, there is a problem when you try to do this naively with ActionMailer. The origin of the problem is TMail, the library ActionMailer uses to do the hard work of parsing and generating emails.
TMail uses its MessageIdHeader class to represent Content-Id headers. This class does some validation and is also used for the Message-Id header. Can you smell the problem already? Message ids must look like somestring@host but you would not assume that you have to format your content ids this way. If you format your Content-Id headers any other way then TMail will simply kick them out (I guess it throws some syntax errors but Rails is swallowing them silently).
To put it in a nutshell: If you need the Content-Id header then format it to look like a Message-Id header.