質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

ログイン

ログインは、ユーザーがコンピューターシステムにアクセスするプロセスの事を呼びます。

メール

メールは、コンピュータネットワークを利用し、 情報等を交換する手段のことです。

Q&A

1回答

829閲覧

Railsアプリのメール機能(アカウント有効化)のエラーが直せません(開発環境のみ。本番環境では問題なし。)

shuhei_rb

総合スコア0

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

ログイン

ログインは、ユーザーがコンピューターシステムにアクセスするプロセスの事を呼びます。

メール

メールは、コンピュータネットワークを利用し、 情報等を交換する手段のことです。

0グッド

0クリップ

投稿2020/07/28 10:30

編集2020/07/28 11:26

前提・実現したいこと

Ruby on Rails でログイン認証機構のシステムを作っています。
開発環境でアカウント有効化やパスワード再設定の際にUserMailer.account_activation(self).deliver_nowによってメールを送信した後のページが上手く表示されなくなってしまいました。

発生している問題・エラーメッセージ

rails serverのログを読むとメールが送信された後に

Completed 500 Internal Server Error in 345ms (ActiveRecord: 12.7ms | Allocations: 15868) Errno::ECONNREFUSED (Connection refused - connect(2) for "localhost" port 25): app/models/user.rb:62:in `send_password_reset_email' app/controllers/password_resets_controller.rb:10:in `create'

のようなエラー文があり、メールはどうやら送信されているみたいで、その後のページ取得のレスポンスが上手くいってなさそうです。

試したこと

Errno::ECONNREFUSED (Connection refused - connect(2) for "localhost" port 25)で検索してみましたが、どれもconfig/environments/development.rbの設定をしていないという理由の物で、自分には該当しないと思っております。このようなメール送信後のページ取得に関して何か原因が分かる方がいらっしゃいましたらご協力お願いします。本番環境(herokuでのデプロイ先)では上手く動いているため開発環境の設定がよくないのかもしれません。自分のconfig/environments/development.rbの内容は以下のようになっています。

Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Do not eager load code on boot. config.eager_load = false # Show full error reports. config.consider_all_requests_local = true # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. if Rails.root.join('tmp', 'caching-dev.txt').exist? config.action_controller.perform_caching = true config.action_controller.enable_fragment_cache_logging = true config.cache_store = :memory_store config.public_file_server.headers = { 'Cache-Control' => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false config.cache_store = :null_store end # Store uploaded files on the local file system (see config/storage.yml for options). config.active_storage.service = :local # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false host = '7dea0eb0d9574e62998253472a0a2fd4.vfs.cloud9.us-east-2.amazonaws.com' config.action_mailer.default_url_options = { host: host, protocol: 'https' } config.action_mailer.perform_caching = false # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. config.assets.debug = true # Suppress logger output for asset requests. config.assets.quiet = true # Raises error for missing translations. # config.action_view.raise_on_missing_translations = true # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. config.file_watcher = ActiveSupport::EventedFileUpdateChecker # Cloud9 への接続を許可する config.hosts.clear end

また、rails serverのログからアカウント有効化のurlを貼り付けるときちんと有効化されます。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

Errno::ECONNREFUSED (Connection refused - connect(2) for "localhost" port 25):
が意味するところは、localhost にメールサーバーが立ち上げって居ない
という可能性が一番高いです。

追記
でそういう場合は localではなく
gmailを使うとか、
ご自宅でPCからメールを出すときに使っているメールサーバーを指定するとか
してください

投稿2020/07/29 12:36

編集2020/07/30 07:48
winterboum

総合スコア23333

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問