File tree 2 files changed +33
-1
lines changed 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
10
10
11
11
For a steady stream of TILs, [ sign up for my newsletter] ( https://tinyletter.com/jbranchaud ) .
12
12
13
- _ 1012 TILs and counting..._
13
+ _ 1013 TILs and counting..._
14
14
15
15
---
16
16
@@ -611,6 +611,7 @@ _1012 TILs and counting..._
611
611
- [ Autosave False On ActiveRecord Associations] ( rails/autosave-false-on-activerecord-associations.md )
612
612
- [ Bind Parameters To ActiveRecord SQL Query] ( rails/bind-parameters-to-activerecord-sql-query.md )
613
613
- [ 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 )
614
615
- [ Capybara Page Status Code] ( rails/capybara-page-status-code.md )
615
616
- [ Cast Common Boolean-Like Values To Booleans] ( rails/cast-common-boolean-like-values-to-booleans.md )
616
617
- [ Change The Nullability Of A Column] ( rails/change-the-nullability-of-a-column.md )
Original file line number Diff line number Diff line change
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 ` .
You can’t perform that action at this time.
0 commit comments