Install and configure mailcatcher for Rails project

Install and start mailcatcher

Type in terminal next commands:

$ gem install mailcatcher
$ mailcatcher

The output to the terminal will be like this

Starting MailCatcher
==> smtp://127.0.0.1:1025
/home/artem/.rvm/gems/ruby-2.6.0@mailcatcher/gems/thin-1.5.1/lib/thin/server.rb:104: warning: constant ::Fixnum is deprecated
==> http://127.0.0.1:1080
*** MailCatcher runs as a daemon by default. Go to the web interface to quit.

Add this config to you environment file, for example: config/environments/staging.rb

config.action_mailer.default_url_options = { host: 'example.com' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { address: '127.0.0.1', port: 1025 }

One of the known problems: NOT USE localhost since it can be resolved on ipv6 address

# config.action_mailer.smtp_settings = { address: 'localhost', port: 1025 }
# config.action_mailer.smtp_settings = { address: '::1', port: 1025 }
comments powered by Disqus