1

如何为多个邮件“操作”重复使用相同的操作邮件模板?

在 ActionController 中,你可以做

...
render :action => 'another_action'

我想同样的事情可以在 ActionMailer 中完成,但我似乎找不到正确的方法。如果它是相关的,我在 Rails 2.3.2 上。

谢谢!

4

1 回答 1

1

您正在寻找 render_message,API Docs Multipart Message部分中有一个很好的示例 - 粘贴在下面。

class ApplicationMailer < ActionMailer::Base
  def signup_notification(recipient)
    recipients      recipient.email_address_with_name
    subject         "New account information"
    from            "system@example.com"
    content_type    "multipart/alternative"

    part :content_type => "text/html",
      :body => render_message("signup-as-html", :account => recipient)

    part "text/plain" do |p|
      p.body = render_message("signup-as-plain", :account => recipient)
      p.transfer_encoding = "base64"
    end
  end
end
于 2009-08-25T03:43:47.113 回答