Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Inline Styles Mailer Gem
tree: 7ee6381368

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
.rspec
.rvmrc
Gemfile
LICENSE
README.md
Rakefile
inline_styles_mailer.gemspec

README.md

Inline Styles Mailer

Using Jack Danger's excellent Inline Styles gem is even easier if you're using Rails 3.1 too.

The Inline Styles gem helps you embed CSS styles into your markup so that you can send pretty HTML emails that won't get butchered by email clients that strip out CSS. Or, more precisely, will help reduce the amount of butchering (even with inline CSS some styles, like background images, are often cut out).

Installation

If you're using bundler:

gem 'inline_styles_mailer'

Usage

If you follow some conventions, then it's just one line:

class FooMailer < ActionMailer::Base
  include InlineStylesMailer

  def foo(email)
    mail(:to => email, :subject => "Foo foo!")
  end

end

If you have a CSS file app/assets/stylesheets/_foo.css.scss then it will get automatically applied to the mail using the inline_styles gem. That name (_foo.css.scss) is based on the mailer class name.

Want to use a different file?

class FooMailer < ActionMailer::Base
  include InlineStylesMailer
  use_stylesheet '_bar'


  def foo(email)
    mail(:to => email, :subject => "Foo foo!")
  end

end

The location of that file, and the fact that it uses SASS is fixed at this time.

Development

Questions or problems? Please post them on the issue tracker. You can contribute changes by forking the project and submitting a pull request. You can ensure the tests passing by running bundle and rake.

This gem was created by Bill Horsman and is under the MIT License.

Something went wrong with that request. Please try again.