ActionMailer previews provide a way to see how our emails look in the browser by visiting a special URL that renders them without actually sending the emails.
It is particularly useful for testing and developing email templates.
Before
By default, Rails looks for mailer previews in the test/mailers/previews
directory.
If we want to customize the location of our mailer previews, we can only specify a single path using the preview_path
configuration, as ActionMailer is limited to one preview path.
For example, if we want to add lib/mailer_previews
to it, we can configure it as
This works well for small to medium apps, but it can become difficult in larger apps where mailer previews need to be organized across multiple directories.
After
Rails 7.1 supports multiple preview paths for mailers with config.action_mailer.preview_paths
Note: With Rails 7.1 config.action_mailer.preview_path
has been deprecated.