[Ruby on Rails 3, Ruby on Rails 4] gems: MailCatcher

心置きなくメール機能開発をするためのダミーSMTPサーバ。
ローカルで完結するため、誤送信の心配がありません。

[markdown]

> * [MailCatcher](http://mailcatcher.me/)

## インストール

“`
$ gem install mailcatcher
“`

## 起動

“`
$ mailcatcher
Starting MailCatcher
==> smtp://127.0.0.1:1025
==> http://127.0.0.1:1080
*** MailCatcher runs as a daemon by default. Go to the web interface to quit.
“`

サーバを起動すると以下の機能が使えるようになります。

* http://localhost:1080/ から送信したメール内容をメールアプリのようなUIで確認できる。
* smtp://localhost:1025/ をSMTPサーバとして利用できる。

## Rails の設定

アドレスとポートの設定のみで利用できます。

“`ruby:config/environments/development.rb
Depot::Application.configure do
# メール送信の設定
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: ‘127.0.0.1’,
port: ‘1025’,
# domain: “test.exsample.com”,
# authentication: “plain”,
# user_name: “”,
# password: “”,
# enable_starttls_auto: true,
}
end
“`

## 事例

PHPから利用した記事があるので、参考下さい。

> * [MailCatcher: ダミーSMTPサーバをつかってメール送信 | deadwood](https://www.d-wood.com/blog/2013/05/22_3674.html)

[/markdown]