mirror of
https://github.com/jbranchaud/til
synced 2026-01-04 23:58:01 +00:00
Add Capture Development Emails With Mailhog as a Rails til
This commit is contained in:
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
|||||||
|
|
||||||
For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud).
|
For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud).
|
||||||
|
|
||||||
_1012 TILs and counting..._
|
_1013 TILs and counting..._
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -611,6 +611,7 @@ _1012 TILs and counting..._
|
|||||||
- [Autosave False On ActiveRecord Associations](rails/autosave-false-on-activerecord-associations.md)
|
- [Autosave False On ActiveRecord Associations](rails/autosave-false-on-activerecord-associations.md)
|
||||||
- [Bind Parameters To ActiveRecord SQL Query](rails/bind-parameters-to-activerecord-sql-query.md)
|
- [Bind Parameters To ActiveRecord SQL Query](rails/bind-parameters-to-activerecord-sql-query.md)
|
||||||
- [Build A Hash Of Model Attributes](rails/build-a-hash-of-model-attributes.md)
|
- [Build A Hash Of Model Attributes](rails/build-a-hash-of-model-attributes.md)
|
||||||
|
- [Capture Development Emails With Mailhog](rails/capture-development-emails-with-mailhog.md)
|
||||||
- [Capybara Page Status Code](rails/capybara-page-status-code.md)
|
- [Capybara Page Status Code](rails/capybara-page-status-code.md)
|
||||||
- [Cast Common Boolean-Like Values To Booleans](rails/cast-common-boolean-like-values-to-booleans.md)
|
- [Cast Common Boolean-Like Values To Booleans](rails/cast-common-boolean-like-values-to-booleans.md)
|
||||||
- [Change The Nullability Of A Column](rails/change-the-nullability-of-a-column.md)
|
- [Change The Nullability Of A Column](rails/change-the-nullability-of-a-column.md)
|
||||||
|
|||||||
31
rails/capture-development-emails-with-mailhog.md
Normal file
31
rails/capture-development-emails-with-mailhog.md
Normal 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`.
|
||||||
Reference in New Issue
Block a user