Introducing letter_opener_web, which is convenient for sending and receiving emails in the development environment with Ruby on Rails.
# Gemfile
group :development do
gem 'letter_opener_web'
end
# config/routes.rb
Rails.application.routes.draw do
root to: 'welcome#index'
# (Abbreviation)
#Write at the very end for letter opener
mount LetterOpenerWeb::Engine, at: '/letter_opener' if Rails.env.development?
end
# config/environments/development.rb
Rails.application.configure do
#Added the following for letter opener
config.action_mailer.default_url_options = { host: 'localhost:3000' }
config.action_mailer.perform_caching = true
config.action_mailer.delivery_method = :letter_opener_web
config.action_mailer.perform_deliveries = true
end
Start the server with the following command.
% rails s
Launch your browser,``` localhost:3000/letter_opener/To access.
The email you sent is displayed.
Click View plain text version You can also check the text mail display.
##Finally It was an introduction of a letter opener that is easy to use. If its helpful then im happy.
Recommended Posts