21
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rails Docker環境でメール送信の動作確認 (mailcatcher)

Posted at

RailsプロジェクトでSMTPサーバ持ってないけど、メール送信機能が正常に動作してるか確認したいとき!
こちらの記事を参考にさせていただきましたが、少しつまずいたの記録します。

docker-compose.yml

docker-compose.yml
  smtp:
    image: schickling/mailcatcher
    ports:
      - "1080:1080"
      - "1025:1025"

development.rb

(つまずいた所)addressはlocalhostではなくdocker-compose.ymlで定義したservice名(smtp)を指定しないとうまくいかない。

config/environments/development.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { :address => "smtp", :port => 1025 }
config.action_mailer.raise_delivery_errors = true

実行

docker-compose up

http://localhost:1080
にアクセスするとWEB上でメールが確認できます。

image.png

rails c rails runner等でメール送信するとこちらに送信されることが確認できます。

動作確認などでご活用ください。
簡単に構築できます。

21
15
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
21
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?