Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Preflight for HTML email

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 bin
Octocat-spinner-32 lib
Octocat-spinner-32 misc
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE.rdoc
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 init.rb
Octocat-spinner-32 local-premailer
Octocat-spinner-32 premailer.gemspec
Octocat-spinner-32 rakefile.rb
README.rdoc

Premailer README

What is this?

For the best HTML e-mail delivery results, CSS should be inline. This is a huge pain and a simple newsletter becomes un-managable very quickly. This script is my solution.

  • CSS styles are converted to inline style attributes Checks style and link[rel=stylesheet] tags and preserves existing inline attributes

  • Relative paths are converted to absolute paths Checks links in href, src and CSS url('')

  • CSS properties are checked against e-mail client capabilities Based on the Email Standards Project's guides

  • A plain text version is created Optional

Premailer 2.0 is coming

I'm looking for input on a version 2.0 update to Premailer. PLease visit the Premailer 2.0 Planning Page and give me your feedback.

Installation

Download the Premailer gem from RubyGems.

sudo gem install premailer

Example

premailer = Premailer.new('http://example.com/myfile.html', :warn_level => Premailer::Warnings::SAFE)

# Write the HTML output
fout = File.open("output.html", "w")
fout.puts premailer.to_inline_css
fout.close

# Write the plain-text output
fout = File.open("ouput.txt", "w")
fout.puts premailer.to_plain_text
fout.close

# Output any CSS warnings
premailer.warnings.each do |w|
  puts "#{w[:message]} (#{w[:level]}) may not render properly in #{w[:clients]}"
end

Contributions

Contributions are most welcome. Premailer was rotting away in a private SVN repository for too long and could use some TLC. Fork and patch to your heart's content. Please don't increment the version numbers, though.

A few areas that are particularly in need of love:

  • Improved test coverage

  • Move un-repeated background images defined in CSS to <td background=""> for Outlook

Credits and code

Thanks to all the wonderful contributors for their updates.

Thanks to Greenhood + Company for sponsoring some of the 1.5.6 updates, and to Campaign Monitor for supporting the web interface.

The web interface can be found at premailer.dialect.ca.

The source code can be found on GitHub.

Copyright by Alex Dunae (dunae.ca, e-mail 'code' at the same domain), 2007-2011. See LICENSE.rdoc for license details.

Something went wrong with that request. Please try again.