For Rails 3, there is now the mail_view
, which was included in Rails 4.1. Here is the setup link. This is pretty easy.
1.) Add to Gemfile:
gem 'mail_view', :git => https:
2.) in routes.rb:
# config/routes.rb if Rails.env.development? mount MailPreview => 'mail_view' end
3.) Create a MailPreview model:
# app/mailers/mail_preview.rb or lib/mail_preview.rb class MailPreview < MailView ... def forgot_password user = Struct.new(:email, :name).new(' name@example.com ', 'Jill Smith') mail = UserMailer.forgot_password(user) end end
In this model, you can name the methods you want, but it makes sense that they correspond to the methods of UserMailer.
4.) To view, go to /mail_view
for a list of all the methods in MailPreview. Click on one to preview HTML preview directly in the browser.
source share