I might be experience complications as I am using letter_opener to check the output in development.
At any rate I have the following code being called when I run an email:
add_attachment('mobile.css')
mail(to: @user.email, subject: @alert.title do |format|
format.html {
Premailer.new(
"#{render}",
:with_html_string => true,
:css => [Rails.root.join("app/assets/mail/basestyles.css"),Rails.root.join("app/assets/mail/" + Site.current.name + ".css")],
:preserve_styles => true
).to_inline_css
}
format.text {
Premailer.new(
"#{render}",
:with_html_string => true,
:css => [Rails.root.join("app/assets/mail/basestyles.css"),Rails.root.join("app/assets/mail/" + Site.current.name + ".css")],
:preserve_styles => true
).to_plain_text
}
end
)
Now this does not raise any errors, but when I run it what I get out is the html file with none of the styles set inline.
The view is rendered correctly, when I run premailer to generate inline styles by itself it works fine, its when I use activemailer I run into problems.
I've looked at How to Integrate 'premailer' with Rails but it does not work for me.