Reputation: 741
I have HTML Emails to be sent from my Rails application. Now I have written inline styles for every element. Now i am trying to use 'roadie' gem to automatically inline my styles which I am gonna write in a seperate stylesheet.
As I am new to use 'roadie' gem I tried writing my styles in head and I sent test Email.
Gemfile
gem 'roadie'
gem 'roadie-rails'
In Mailer-layout
<head>
<style type="text/css">
.logo{
vertical-align: top;
padding-bottom: 0;
padding-left: 14%;
margin: 0;
}
</style>
</head>
<body>
<td class="RB-logo">......................</td>
</body>
But In GMail, it does not accept my styles I have in
What Am I doing wrong?
Upvotes: 1
Views: 1313
Reputation: 741
'roadie'rails' was the one did the magic.
In my Gemfile
gem 'roadie-rails'
In my mailers.rb
include Roadie::Rails::Automatic
THis does the magic.
Upvotes: 1
Reputation: 4403
This is how I use roadie gem in every application and it's working:
Version: 2.4.3
layouts/mailer.html.haml
!!!
%html
%head
%title X
%style{type: "text/css"}
= render "shared/mailer_css"
%body{bgcolor: "#FFFFFF"}
// CONTENT
mailers/x_mailer.rb
class XMailer < ActionMailer::Base
layout "mailer"
end
shared/_mailer_css.html
* {
margin: 0;
padding: 0;
font-family: 'Open Sans', sans-serif;
font-family: 'Open Sans', sans-serif;
}
.text-left{
text-align: left;
}
// Others
I'm not sure why but sometimes you need to restart your server for emails to display correctly on the localhost, if you are using the letter-opener gem.
Another note: I use only roadie without roadie-rails
Upvotes: 0