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.
August 31st, 2010 at 2:20 am
Fed up with getting low amounts of useless traffic for your site? Well i wish to share with you a new underground tactic that produces me personally $900 each day on 100% AUTOPILOT. I possibly could be here all day and going into detail but why dont you simply check their site out? There is a excellent video that explains everything. So if your seriously interested in producing simple money this is the website for you. Auto Traffic Avalanche