Hacker News new | ask | show | jobs
by sundance0 4322 days ago
These are great, and really simple to use. Already adapted for my latest project!

Also, if you didn't catch it in there: the [premailer][1] library is awesome, and helps make email templates more manageable (use CSS/LESS/SCSS styles like normal, then run your HTML email through premailer before shipping and it'll inline everything for you). I use the Python library with Django to preflight emails before sending. Works like a charm!

[1]: https://github.com/peterbe/premailer/tree/master

Also available in Ruby, Node, and PHP flavors

4 comments

The original post and your comment both make it sounds like the various premailer libraries all share a common core, but I don't think that is true. Does the python premailer have anything to do with premailer.dialect.ca? I don't think it does.

Several months ago, when I was using Zurb Ink to design some emails, the python premailer would choke on some of the responsive CSS. I had to switch to the ruby premailer gem to get things to work. It looks like the python premailer has since been updated, so perhaps it works now.

Why is it better to use inline CSS here? Isn't inline CSS usually frowned-upon?
> Isn't inline CSS usually frowned-upon?

Yes, but not in the 1990s, which is the era HTML email finds itself stuck in.

Email clients strip external css and often the style tag. Therefore you have to use inline css to style html emails.
Most browser-based email clients (Gmail, Yahoo, etc.) strip out the head and body tags from HTML emails. You never really know what's going to be removed, so the safest thing is to inline all of your styles.
Yes. But generally when things are frowned-upon, it's because they have something going for them. (If everyone agrees that something is dumb, there's no point in belaboring it.) Inlining is the simplest and most fool-proof way to apply CSS, which helps explain why it works in email where all else fails.
Premailer is amazing. Saves me a huge amount of trouble regularly. For one thing you can just remove the external stylesheet reference to see how it degrades instead of s/style=/ignorestyle=/g or similar.
One of the core features of Sendwithus that we DON'T talk about is the fact that we inline css for you at send time.

Such a pain to build out a inlining and testing workflow for content that should be in some kind of cms.