gshaw / notes

Issues and solutions I find during software development.
https://gshaw.ca
MIT License
1 stars 0 forks source link

Capture development emails with Mailpit #18

Open gshaw opened 10 months ago

gshaw commented 10 months ago

My preferred way to capture and view emails being sent by a Rails app in development is to use Mailpit. It runs a local SMTP server at port 1025 and a barebones email client at port 8025. I used to use MailHog but development has stalled. Mailpit has the same ease of use while supporting newer features and looking nicer.

The mailpit utility can be installed with brew:

brew install mailpit
brew services start mailpit

The development smtp settings are configured in config/environments/development.rb:

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { address: "localhost", port: 1025 }

All outgoing email from the development server will be captured and viewable in both html and text form at localhost:8025.

Source: https://github.com/jbranchaud/til/blob/master/rails/capture-development-emails-with-mailhog.md

gshaw commented 10 months ago

See https://www.jdeen.com/blog/configure-default-url-options-on-rails for more information about getting routes to work with a hostname in development.