1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-06 00:28:01 +00:00

Add Capture Development Emails With Mailhog as a Rails til

This commit is contained in:
jbranchaud
2021-01-16 17:42:56 -06:00
parent d4414c66f6
commit 3ce54d471e
2 changed files with 33 additions and 1 deletions

View File

@@ -0,0 +1,31 @@
# Capture Development Emails With Mailhog
My preferred way to capture and view emails being sent by a Rails app in
development is to use [MailHog](https://github.com/mailhog/MailHog). It runs a
local SMTP server at port `1025` and a barebones email client at port `8025`.
The `mailhog` utility can be installed with `brew`:
```bash
$ brew install mailhog
```
The development `smtp` settings are configured in
`config/environments/development.rb`:
```ruby
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'localhost',
port: 1025,
}
```
Then start running `mailhog` with its default settings:
```bash
$ mailhog
```
All outgoing email from the development server will be captured and viewable in
both `html` and `text` form at `localhost:8025`.