如何将'premailer' gem 与Rails(3.0.7)项目集成在一起?我目前在邮件中:

def welcome(user)
  @user = user

  mail to: user.email, subject: "Welcome"
end

但是我不知道如何集成该库。我需要调用:
premailer = Premailer.new(html)
html = premailer.to_inline_css

但是,我不确定如何通过邮件操作访问电子邮件的内容。

最佳答案

尝试:

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, with_html_string: true).to_inline_css

  return message
end

def welcome(user)
  @user = user

  message = mail to: user.email, subject: "Welcome"
end

关于ruby-on-rails - 如何将 'premailer'与Rails集成,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6127068/

10-13 02:10