Better Mailer Previews 是一个 Ruby on Rails 插件,可让您更轻松地预览 ActionMailer 电子邮件模板。
Better Mailer Previews 是一个 Ruby on Rails 插件,可让您更轻松地预览 ActionMailer 电子邮件模板。
Better Mailer Previews is a Ruby on Rails gem that makes previewing all your ActionMailer email templates easier.
This gem/engine builds on top of native Rails mailer previews, with a few key enhancements like —
Here's a little demo I've put together ↓
I've used native Rails mailer previews extensively for building my ActionMailer email templates, but they're pretty barebones and lacking. In particular, I wanted a way to bulk-preview templates (rather than checking them one by one). I also wanted to be able to easily resize the email container for testing responsive layouts.
This gem is my idea brought to life, and I hope you'll find it useful!
group :development do
...
gem "better_mailer_previews"
end$ bundleroutes.rb file —# routes.rb
Rails.application.routes.draw do
mount BetterMailerPreviews::Engine, at: "/better_mailer_previews" if Rails.env.development?
...
endlocalhost:3000/better_mailer_previews.This gem let's you send your email previews to an email address, using whatever default delivery method you have configured.
Better Mailer Previews sends it's emails using whichever config.action_mailer.delivery_method is defined for the environment. For example, if you're using Mailhog in development to test your emails, you might have a configuration like this —
# config/environments/development.rb
#
Rails.application.configure do
...
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {address: "127.0.0.1", port: 1025}
config.action_mailer.raise_delivery_errors = false
endIn this case, Better Mailer Previews will send it's emails to Mailhog too (since it uses your existing configuration). If you want to send emails to a live inbox (like your personal email), you'd need to configure a live delivery method for the current environment.
This engine will display all the Actionmailer Previews defined in the host Ruby on Rails app. These are the mailer previews you've defined in test/mailers/previews, for use with native Actionmailer Previews.
For all the mailers you'd like to preview, you need to set up the corresponding ActionMailer::Preview class. Once you've done that, this engine will automatically pull them all in and let you preview them!
If you like this gem, you'll probably like some of my other work (all Ruby on Rails stuff) —
If you want updates, you can also follow me on Twitter
The gem is available as open source under the terms of the MIT License.
暂无开放 Issues,或尚未同步最近议题。