Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Inline Styles Mailer Gem

tree: 7ee6381368

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore Initial commit December 05, 2011
Octocat-spinner-32 .rspec
Octocat-spinner-32 .rvmrc
Octocat-spinner-32 Gemfile
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 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.