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

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

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

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

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Q&A

0回答

511閲覧

railsのaction mailerとamazon SESの設定

MasakazuFukami

総合スコア1869

Ruby on Rails

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

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

0グッド

0クリップ

投稿2017/09/27 03:18

編集2017/12/13 09:09

いつもお世話になっております。
現在railsとamazon SESを使用し、ユーザーパスワードリセット機能を作成しています。

ユーザストーリーとしては以下のようになります。

  1. パスワード忘れた方はこちら
  2. メールアドレスにパスワードリセット用のメールを送信
  3. メール内に書かれてあるリンクを踏むとパスワードリセットページに飛ぶ
  4. パスワードを再設定

上記の流れの「メールアドレスにパスワードリセット用のメールを送信」で現在詰まっています。

SESの方の設定は完了しているつもりです。

development.rb以下にaction_mailerの設定を行なっております。
自分で調べた結果、STARTTLS系のエラーかなぁと思っているのですが、現在解決することが出来ていません。
ちなみにアプリのローカルurlはlocalhost:3000となっています。

以下に設定ファイルとログを記述するので解決方法をご教授いただけないでしょうか。

config/environments/development.rb

ruby

1Rails.application.configure do 2 ... 3 4 # deviseの設定 5 config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } 6 config.action_mailer.delivery_method = :smtp 7 8 config.action_mailer.smtp_settings = { 9 address: 'email-smtp.us-east-1.amazonaws.com', 10 port: 587, 11 authentication: :login, 12 user_name: '[SES UserName]', //SESのusername 13 password: '[SEP Password]', //SESのpassword 14 enable_starttls_auto: true 15 } 16end 17

app/mailer

app/mailer配下には以下の1ファイルしか入っていませんでした。。。
application_mailr.rb

class ApplicationMailer < ActionMailer::Base default from: "from@example.com" layout "mailer" end

ログ

Started POST "/users/password" for 172.18.0.1 at 2017-09-27 02:55:35 +0000 ... <p>Hello test@gmail.com!</p> <p>Someone has requested a link to change your password. You can do this through the link below.</p> <p><a href="http://localhost:3000/users/password/edit?reset_password_token=EoGaE1UF2KjTNFLGHhvQ">Change my password</a></p> <p>If you didn't request this, please ignore this email.</p> <p>Your password won't change until you access the link above and create a new one.</p> Completed 500 Internal Server Error in 6247ms (ActiveRecord: 4.1ms) Net::SMTPFatalError (553 <localhost:3000> Invalid email address. ): /usr/local/lib/ruby/2.4.0/net/smtp.rb:969:in `check_response' /usr/local/lib/ruby/2.4.0/net/smtp.rb:937:in `getok' /usr/local/lib/ruby/2.4.0/net/smtp.rb:837:in `mailfrom' /usr/local/lib/ruby/2.4.0/net/smtp.rb:658:in `send_message' mail (2.6.6) lib/mail/network/delivery_methods/smtp.rb:112:in `block in deliver!' /usr/local/lib/ruby/2.4.0/net/smtp.rb:519:in `start' mail (2.6.6) lib/mail/network/delivery_methods/smtp.rb:111:in `deliver!' mail (2.6.6) lib/mail/message.rb:2149:in `do_delivery' mail (2.6.6) lib/mail/message.rb:237:in `block in deliver' actionmailer (5.1.3) lib/action_mailer/base.rb:558:in `block in deliver_mail' activesupport (5.1.3) lib/active_support/notifications.rb:166:in `block in instrument' activesupport (5.1.3) lib/active_support/notifications/instrumenter.rb:21:in `instrument' activesupport (5.1.3) lib/active_support/notifications.rb:166:in `instrument' actionmailer (5.1.3) lib/action_mailer/base.rb:556:in `deliver_mail' mail (2.6.6) lib/mail/message.rb:237:in `deliver' actionmailer (5.1.3) lib/action_mailer/message_delivery.rb:96:in `block in deliver_now' actionmailer (5.1.3) lib/action_mailer/rescuable.rb:15:in `handle_exceptions' actionmailer (5.1.3) lib/action_mailer/message_delivery.rb:95:in `deliver_now' devise (4.3.0) lib/devise/models/authenticatable.rb:191:in `send_devise_notification' devise (4.3.0) lib/devise/models/recoverable.rb:97:in `send_reset_password_instructions_notification' devise (4.3.0) lib/devise/models/recoverable.rb:50:in `send_reset_password_instructions' devise (4.3.0) lib/devise/models/recoverable.rb:134:in `send_reset_password_instructions' devise (4.3.0) app/controllers/devise/passwords_controller.rb:13:in `create' action_args (2.2.1) lib/action_args/abstract_controller.rb:13:in `send_action' actionpack (5.1.3) lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action' actionpack (5.1.3) lib/abstract_controller/base.rb:186:in `process_action' actionpack (5.1.3) lib/action_controller/metal/rendering.rb:30:in `process_action' actionpack (5.1.3) lib/abstract_controller/callbacks.rb:20:in `block in process_action' activesupport (5.1.3) lib/active_support/callbacks.rb:131:in `run_callbacks' actionpack (5.1.3) lib/abstract_controller/callbacks.rb:19:in `process_action' actionpack (5.1.3) lib/action_controller/metal/rescue.rb:20:in `process_action' actionpack (5.1.3) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action' activesupport (5.1.3) lib/active_support/notifications.rb:166:in `block in instrument' activesupport (5.1.3) lib/active_support/notifications/instrumenter.rb:21:in `instrument' activesupport (5.1.3) lib/active_support/notifications.rb:166:in `instrument' actionpack (5.1.3) lib/action_controller/metal/instrumentation.rb:30:in `process_action' actionpack (5.1.3) lib/action_controller/metal/params_wrapper.rb:252:in `process_action' activerecord (5.1.3) lib/active_record/railties/controller_runtime.rb:22:in `process_action' actionpack (5.1.3) lib/abstract_controller/base.rb:124:in `process' actionview (5.1.3) lib/action_view/rendering.rb:30:in `process' actionpack (5.1.3) lib/action_controller/metal.rb:189:in `dispatch' actionpack (5.1.3) lib/action_controller/metal.rb:253:in `dispatch' actionpack (5.1.3) lib/action_dispatch/routing/route_set.rb:49:in `dispatch' actionpack (5.1.3) lib/action_dispatch/routing/route_set.rb:31:in `serve' actionpack (5.1.3) lib/action_dispatch/routing/mapper.rb:16:in `block in <class:Constraints>' actionpack (5.1.3) lib/action_dispatch/routing/mapper.rb:46:in `serve' actionpack (5.1.3) lib/action_dispatch/journey/router.rb:46:in `block in serve' actionpack (5.1.3) lib/action_dispatch/journey/router.rb:33:in `each' actionpack (5.1.3) lib/action_dispatch/journey/router.rb:33:in `serve' actionpack (5.1.3) lib/action_dispatch/routing/route_set.rb:834:in `call' warden (1.2.7) lib/warden/manager.rb:36:in `block in call' warden (1.2.7) lib/warden/manager.rb:35:in `catch' warden (1.2.7) lib/warden/manager.rb:35:in `call' rack (2.0.3) lib/rack/etag.rb:25:in `call' rack (2.0.3) lib/rack/conditional_get.rb:38:in `call' rack (2.0.3) lib/rack/head.rb:12:in `call' rack (2.0.3) lib/rack/session/abstract/id.rb:232:in `context' rack (2.0.3) lib/rack/session/abstract/id.rb:226:in `call' actionpack (5.1.3) lib/action_dispatch/middleware/cookies.rb:613:in `call' activerecord (5.1.3) lib/active_record/migration.rb:556:in `call' actionpack (5.1.3) lib/action_dispatch/middleware/callbacks.rb:26:in `block in call' activesupport (5.1.3) lib/active_support/callbacks.rb:97:in `run_callbacks' actionpack (5.1.3) lib/action_dispatch/middleware/callbacks.rb:24:in `call' actionpack (5.1.3) lib/action_dispatch/middleware/executor.rb:12:in `call' actionpack (5.1.3) lib/action_dispatch/middleware/debug_exceptions.rb:59:in `call' web-console (3.5.1) lib/web_console/middleware.rb:135:in `call_app' web-console (3.5.1) lib/web_console/middleware.rb:28:in `block in call' web-console (3.5.1) lib/web_console/middleware.rb:18:in `catch' web-console (3.5.1) lib/web_console/middleware.rb:18:in `call' actionpack (5.1.3) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call' railties (5.1.3) librack/logger.rb:36:in `call_app' railties (5.1.3) librack/logger.rb:24:in `block in call' activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `block in tagged' activesupport (5.1.3) lib/active_support/tagged_logging.rb:26:in `tagged' activesupport (5.1.3) lib/active_support/tagged_logging.rb:69:in `tagged' railties (5.1.3) librack/logger.rb:24:in `call' sprockets-rails (3.2.0) lib/sprocketsquiet_assets.rb:13:in `call' actionpack (5.1.3) lib/action_dispatch/middleware/remote_ip.rb:79:in `call' request_store (1.3.2) lib/request_store/middleware.rb:9:in `call' actionpack (5.1.3) lib/action_dispatch/middleware/request_id.rb:25:in `call' rack (2.0.3) lib/rack/method_override.rb:22:in `call' rack (2.0.3) lib/rack/runtime.rb:22:in `call' activesupport (5.1.3) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call' actionpack (5.1.3) lib/action_dispatch/middleware/executor.rb:12:in `call' actionpack (5.1.3) lib/action_dispatch/middleware/static.rb:125:in `call' rack (2.0.3) lib/rack/sendfile.rb:111:in `call' rack-cors (1.0.1) lib/rack/cors.rb:93:in `call' railties (5.1.3) libengine.rb:522:in `call' puma (3.9.1) lib/puma/configuration.rb:224:in `call' puma (3.9.1) lib/puma/server.rb:602:in `handle_request' puma (3.9.1) lib/puma/server.rb:435:in `process_client' puma (3.9.1) lib/puma/server.rb:299:in `block in run' puma (3.9.1) lib/puma/thread_pool.rb:120:in `block in spawn_thread' Completed 500 Internal Server Error in 84ms (Views: 73.1ms | ActiveRecord: 0.0ms)
Net::SMTPFatalError (553 <localhost:3000> Invalid email address.):

localhost:3000に対してInvalid email addressが出るのは言葉としては理解できるのですが、どこでlocalhost:3000をメールアドレスにしているのかがわかりません。。。

よろしくお願いいたします。

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

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

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

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

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

y_y3

2017/09/27 03:31

app/mailer/ 以下のファイルはどうなっていますか?
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

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

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

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問