Preview hanami emails in browser

Sometimes you need to preview your emails in development enviroment. For this you can use use letter_opener gem. Because hanami uses mail gem, letter_opener integration will be easy. Firstly you need add gem to your Gemfile:

gem "letter_opener", group: :development

Secondly you need add new delivery method to your lib/repository_name.rb file:

require "letter_opener"
Hanami::Mailer.configure do
  delivery do
    development LetterOpener::DeliveryMethod, location: Hanami.root.join('tmp/letter_opener')

After that when you deliver your email, letter_opener will generate html files that users will see in tmp/letter_opener directory.