Ruby on rails 将premailer gem与Rails 2.X应用程序集成

Ruby on rails 将premailer gem与Rails 2.X应用程序集成,ruby-on-rails,ruby,actionmailer,ruby-on-rails-2,premailer,Ruby On Rails,Ruby,Actionmailer,Ruby On Rails 2,Premailer,我有一个rails 2.3应用程序,希望将应用程序集成到其中。 我发现如何为rails 3.X应用程序实现这一点: 有人知道如何为action mailer 2.3.10做到这一点吗?最近几天我花了很多时间在这方面,似乎没有什么好的解决方案。可以显式地呈现消息,然后通过预编译器传递结果,但如果模板使用ASCII-8BIT以外的其他编码,则与多部分电子邮件和HTML布局相结合,结果会变得混乱 在一封没有多部分的直接HTML电子邮件中,假设使用ASCII-8BIT编码模板,这对我来说很有用: def

我有一个rails 2.3应用程序,希望将应用程序集成到其中。 我发现如何为rails 3.X应用程序实现这一点:
有人知道如何为action mailer 2.3.10做到这一点吗?

最近几天我花了很多时间在这方面,似乎没有什么好的解决方案。可以显式地呈现消息,然后通过预编译器传递结果,但如果模板使用ASCII-8BIT以外的其他编码,则与多部分电子邮件和HTML布局相结合,结果会变得混乱

在一封没有多部分的直接HTML电子邮件中,假设使用ASCII-8BIT编码模板,这对我来说很有用:

def some_email
    recipients   "Reciever <reciever@example.com>"
    from         "Sender <sender@example.com>"
    subject      "Hello"
    content_type "text/html"

    message = render_message("some_email", { }) # second argument is a hash of locals
    p.body = Premailer.new(message, with_html_string: true).to_inline_css
end
def some_multipart_email
    recipients   "Reciever <reciever@example.com>"
    from         "Sender <sender@example.com>"
    subject      "Hello"
    content_type "text/html"

    part "text/html" do |p|
        message = render_message("some_email_html", { })
        p.body = Premailer.new(message, with_html_string: true).to_inline_css
    end

    part "text/plain" do |p|
        p.content_type = "text/plain"
        p.body = render(file: "some_email_text", body: { }, layout: false)
    end
end