tags:

views:

206

answers:

3

Because some email clients don't properly render external stylesheets (or even styles within the <head> of an HTML email message), inlining CSS is a common approach to try to maintain consistent look and feel between a website and emails. But manually inlining styles is painful and error prone.

I'm looking for a way to let users create messages using the same stylesheet as their website uses, but then converting the text into a more email appropriate format prior to sending. While it's certainly possible to write a tool that reads styles and the DOM, injecting the correct inline style for each element, I'm hoping there's already a tool available that does this. Unfortunately, my googling hasn't yielded any useful results.

Do you know of any tools that can inline CSS styles? I'm not picky about the language, though if it's not open source, I'll probably just write my own.

+1  A: 

The premailer at http://code.dunae.ca/premailer.web/ is a good tool if your layout is straightforward and your HTML is tidy. It behaves poorly on badly-formatted HTML though, I don't know if it's something you'd refer a client to.

Source is available at http://code.google.com/p/premailer/. MIT License.

anschauung
There's a new version here http://premailer.dialect.ca/
jao
+1  A: 

There is also premailer as a Python package.

muhuk