Skip to content

Letter Opener Reply

andyl edited this page Aug 23, 2013 · 2 revisions

In my rails app, I did a simple hack to enable email replies from letter_opener. I did this to to simulate two-way email traffic in a group messaging system.

letter_opener_reply

How it works:

  1. Override LetterOpener::Message#template - put this code in lib/letter_opener/alt_template:
module LetterOpener
  class Message
    def template
      File.read(File.expand_path("../message.html.erb", __FILE__))
    end
  end
end
  1. Drop this template into lib/letter_opener/message.html.erb

  2. Add require_relative "../lib/letter_opener/alt_template.rb" to config/application.rb. Now letter_opener should display the reply form.

  3. Create a controller letter_opener_reply_controller.rb and modify routes.rb as needed. Now your rails app should process the letter_opener reply.

Hope that this tip is useful to someone else who would like to add a reply feature to letter_opener.

Clone this wiki locally