premailer

How to Integrate 'premailer' with Rails

此生再无相见时 提交于 2019-12-12 07:14:39
问题 How does one integrate the 'premailer' gem with a Rails (3.0.7) project? I currently have in my mailer: def welcome(user) @user = user mail to: user.email, subject: "Welcome" end But I can't figure out how to integrate the library. I need to call: premailer = Premailer.new(html) html = premailer.to_inline_css However, I'm not sure how to access the contents of my email from a mailer action. 回答1: Try: def premailer(message) message.text_part.body = Premailer.new(message.text_part.body.to_s,

How to Integrate 'premailer' with Rails

两盒软妹~` 提交于 2019-11-30 12:54:39
How does one integrate the ' premailer ' gem with a Rails (3.0.7) project? I currently have in my mailer: def welcome(user) @user = user mail to: user.email, subject: "Welcome" end But I can't figure out how to integrate the library. I need to call: premailer = Premailer.new(html) html = premailer.to_inline_css However, I'm not sure how to access the contents of my email from a mailer action. Try: def premailer(message) message.text_part.body = Premailer.new(message.text_part.body.to_s, with_html_string: true).to_plain_text message.html_part.body = Premailer.new(message.html_part.body.to_s,