#つまずいている事
rails初心者です。
現在、rails tutorialの11章を進めています。
章の最後に本番環境でsendgridを使いアカウントの有効化メールを配信する段階で
メールが送られてこない状況です。かれこれ半日試行錯誤しており助けて頂けると大変有り難いです。。
#実行したコマンド
①heroku addons:create sendgrid:starter(ここでherokuアドオン機能を使用するためクレジットカードの登録。)
②heroku addons:add sendgrid:starter
③heroku config:get SENDGRID_USERNAME
④heroku config:get SENDGRID_PASSWORD(③④のコマンドは中身を確認しただけ?)
⑤git add -A
⑥git commit -m "Add account activation"
⑦git checkout master
⑧git merge account-activation
⑨git push
⑩git push heroku
⑪heroku run rails db:migrate
#メールがこないことに対する対処
①SendgridのActivity feedを確認し、
そこまでは処理が進んでいることを確認できた。
②環境変数の中身を上記③④のコマンドで出力されたものを記載して見たり
コードは色々といじりましたが、最終的に設定は下記で記載しました。
#production環境でSendGridを使う設定(config/environments/production.rb)
ruby
1. 2. 3config.action_mailer.perform_caching = false 4config.action_mailer.raise_delivery_errors = true 5 config.action_mailer.delivery_method = :smtp 6 host = '自分のアプリのhost名.herokuapp.com' 7 config.action_mailer.default_url_options = { host: host } 8 ActionMailer::Base.smtp_settings = { 9 :address => 'smtp.sendgrid.net', 10 :port => '587', 11 :authentication => :plain, 12 :user_name => ENV['SENDGRID_USERNAME'], 13 :password => ENV['SENDGRID_PASSWORD'], 14 :domain => 'heroku.com', 15 :enable_starttls_auto => true 16 } 17. 18. 19
#お願い
一人では解決が難しいため
どなたかアドバイスをよろしくお願いします。
以上です。
回答1件
あなたの回答
tips
プレビュー