Last Updated: February 25, 2016
·
1.239K
· daveobriencouk

Installing the Premailer gem

Premailer is awesome. It converts linked and embedded CSS styles to inline style attributes. Alongside this, it converts relative paths, checks links, creates a plain text email and even checks email client capabilities.

You can use the web app and either paste your code or pull the email from a URL. This is pretty useful, however it can get a bit laborious when going through the testing motions. A more integrated approach would be sweet, which is where the premailer Ruby gem comes in.

Once installed you can run commands like premailer inputfile.html > outputfile.html to generate the inlined email ( full details on command line usage can be found here ).

Super simple, however the install was not (at least on Mac OS 10.9).

The gem requires a HTML parser - Nokogiri which was difficult to install, even through homebrew. However, I found a ruby script that installed Nokogiri successfully.

Simply download the script, navigate to the containing folder in Terminal and run ruby macfix1-install-nokogiri.rb.