Skip to content

Commit 3ce54d4

Browse files
committed
Add Capture Development Emails With Mailhog as a Rails til
1 parent d4414c6 commit 3ce54d4

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
1010

1111
For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud).
1212

13-
_1012 TILs and counting..._
13+
_1013 TILs and counting..._
1414

1515
---
1616

@@ -611,6 +611,7 @@ _1012 TILs and counting..._
611611
- [Autosave False On ActiveRecord Associations](rails/autosave-false-on-activerecord-associations.md)
612612
- [Bind Parameters To ActiveRecord SQL Query](rails/bind-parameters-to-activerecord-sql-query.md)
613613
- [Build A Hash Of Model Attributes](rails/build-a-hash-of-model-attributes.md)
614+
- [Capture Development Emails With Mailhog](rails/capture-development-emails-with-mailhog.md)
614615
- [Capybara Page Status Code](rails/capybara-page-status-code.md)
615616
- [Cast Common Boolean-Like Values To Booleans](rails/cast-common-boolean-like-values-to-booleans.md)
616617
- [Change The Nullability Of A Column](rails/change-the-nullability-of-a-column.md)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Capture Development Emails With Mailhog
2+
3+
My preferred way to capture and view emails being sent by a Rails app in
4+
development is to use [MailHog](https://github.com/mailhog/MailHog). It runs a
5+
local SMTP server at port `1025` and a barebones email client at port `8025`.
6+
7+
The `mailhog` utility can be installed with `brew`:
8+
9+
```bash
10+
$ brew install mailhog
11+
```
12+
13+
The development `smtp` settings are configured in
14+
`config/environments/development.rb`:
15+
16+
```ruby
17+
config.action_mailer.delivery_method = :smtp
18+
config.action_mailer.smtp_settings = {
19+
address: 'localhost',
20+
port: 1025,
21+
}
22+
```
23+
24+
Then start running `mailhog` with its default settings:
25+
26+
```bash
27+
$ mailhog
28+
```
29+
30+
All outgoing email from the development server will be captured and viewable in
31+
both `html` and `text` form at `localhost:8025`.

0 commit comments

Comments
 (0)