# AwesomeMailer
AwesomeMailer is an ActionMailer extension that supports rad stuff like inline CSS embedded through `stylesheet_link_tag` or just, you know, stylesheets.
## Installation
Add this to your Gemfile:
gem 'awesomemailer'
Or if you're old-fashioned, do this:
gem install awesomemailer
Then `require 'awesome_mailer'` and follow the example below.
## Example
Suppose you have the following mailer:
class UserMailer < ActionMailer::Base
def signup(user_id)
@user = User.find(user_id)
mail(:to => @user.email, :from => "no-reply@example.com")
end
end
... and you have a template `app/views/user_mailer/signup.html.erb`. It might look something like this:
<%= stylesheet_link_tag 'email' %>
Welcome to AwesomeMailer, <%= @user.name %>! We think you might be neat.
... and your style sheet (email.css) might be kinda like this:
body {
background: #f0f0f0;
font: 12pt Arial normal;
}
a img {
border-width: 0;
}
#header {
border-bottom: 1px solid black;
margin-bottom: 1em;
}
#content {
font-family: Helvetica;
padding: 1em 0;
}
#content p {
line-height: 1.3em;
}
#footer {
border-top: 1px dotted orange;
font-size: 10pt;
}
... you might be unhappy because most mail viewers couldn't care less that you included a stylesheet. But wait!
There's AwesomeMailer! Just change your mailer to look like this:
class UserMailer < AwesomeMailer::Base
... and voila! Now your templates will render like this:
Welcome to AwesomeMailer, <%= @user.name %>! We think you might be neat.
WOW!
## Additional Features
### @import
AwesomeMailer (or really, the library it relies on, CSS parser) is smart enough to load up stylesheets through
@import statements. So go ahead and add `@import url('global.css')` to email.css, and we'll handle the rest.
### Pseudo-classes
AwesomeMailer supports more than just inline styles. If you define pseudo-classes like :hover, :after, etc, it'll
make sure they get included in a <style> tag in the <head> of your e-mail. Don't have a <head>? That's cool;
AwesomeMailer will add one.
### @font-face
AwesomeMailer will also load up font-face declarations, if'n you have 'em. That means you can add custom fonts to
your e-mails the same way you do with your websites, and if your user's mail client supports them, UP they'll go!
## Bugs
File bugs using the issues tab in Github. **Don't** e-mail me. _Please_.
## LEGAL FUNSIES
AwesomeMailer is copyright (c) 2011 Delightful Widgets Inc.
It was built by Flip Sasser (flip@x451.com) using libraries from Alex Dunae
([https://github.com/alexdunae/css_parser](https://github.com/alexdunae/css_parser)) and, as far as I know, Nick Sieger
([https://github.com/hpricot/hpricot](https://github.com/hpricot/hpricot)). Those guys are AWESOME. Be their friends.