Skip to content

Making HTML emails a little less painful. Writes css inline and corrects image urls.

License

Notifications You must be signed in to change notification settings

mattsmith/mail_style

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About fork

This is a for of original mail_style gem to add new rails 3 action mailer support. Works only with Rails 3.
For original gem look at http://github.com/purify/mail_style

Install

Add to your Gemfile

gem 'mail_style', :git => 'git://github.com/uzzz/mail_style.git'

Usage

Simply add the css parameter to mail method:

class Notifier < ActionMailer::Base
  def welcome_email
    mail(:subject => 'Welcome Abroad', :from => 'jimneath@googlemail.com', :to => 'recipient@example.com', :css => 'email')
  end

or to defaults hash

class Notifier < ActionMailer::Base
  default :css => 'email'

  def welcome_email
    ...
  end

  def digest_email
    ...
  end

This will look for a css file called email.css in your public/stylesheets folder. The css method can take either a string or a symbol. You can also pass the css file name with or without the .css extension.

Styles in the email’s HEAD

By default, <style> elements in the email document’s <head> are processed and removed from the <head>.

Style elements with media="print" are ignored.

You can set a special data-immutable="true" attribute on <style> tags you do not want to be processed and removed from the document’s <head>.

Image URL Correcting

If you have default_url_options[:host] set in your mailer, then MailStyle will do it’s best to make the urls of images absolute.

In your mailer

ActionMailer::Base.default_url_options[:host] = "example.com"

Features

  • Write CSS styles inline
  • Corrects image urls
  • SASS Support

Bugs / Todo

  • Improve overall performance
  • Add support for less
  • Allow users to swap between css_parser and csspool

Contributors

License

(The MIT License)

Copyright © 2009-2010

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Making HTML emails a little less painful. Writes css inline and corrects image urls.

Resources

License

Stars

Watchers

Forks

Packages

No packages published