2020/10/28 07:36 編集
まちがい
投稿2020/10/28 04:36
本番環境でメール送信がしたいです
今自分はユーザー登録したユーザーに対してメールを送っていて、ユーザーがそのメールのリンクをクリックしたらアカウント認証できるみたいなことをしたいのですが、本番環境では上手く動きません。
somthing went wrongになってしまいます
2020-10-28T04:03:30.750599+00:00 app[web.1]: D, [2020-10-28T04:03:30.750447 #18] DEBUG -- : [2bf4683b-f3aa-479c-a58d-8a07ccb733d5] (2.4ms) BEGIN 2020-10-28T04:03:30.752209+00:00 app[web.1]: D, [2020-10-28T04:03:30.752128 #18] DEBUG -- : [2bf4683b-f3aa-479c-a58d-8a07ccb733d5] User Exists? (1.3ms) SELECT 1 AS one FROM "users" WHERE LOWER("users"."email") = LOWER($1) LIMIT $2 [["email", "hr@gmail.commmmm"], ["LIMIT", 1]] 2020-10-28T04:03:31.138021+00:00 app[web.1]: D, [2020-10-28T04:03:31.137842 #18] DEBUG -- : [2bf4683b-f3aa-479c-a58d-8a07ccb733d5] User Create (1.8ms) INSERT INTO "users" ("name", "email", "created_at", "updated_at", "password_digest", "activation_digest") VALUES ($1, $2, $3, $4, $5, $6) RETURNING "id" [["name", "そうちゃん"], ["email", "sample41soccer@gmail.commmmm"], ["created_at", "2020-10-28 04:03:30.752702"], ["updated_at", "2020-10-28 04:03:30.752702"], ["password_digest", "$2a$12$CEIuzvx8vXLE9affFNOHI.sGS6xsuKdVst6aYxZsScqIgyU1IjBKq"], ["activation_digest", "$2a$12$RWYlbyN.Ne8HK3HnUnMM3eNtIeuvH6egCndHd5pckY/7PgK2NuYSW"]] 2020-10-28T04:03:31.141401+00:00 app[web.1]: D, [2020-10-28T04:03:31.141215 #18] DEBUG -- : [2bf4683b-f3aa-479c-a58d-8a07ccb733d5] (2.5ms) COMMIT 2020-10-28T04:03:31.147785+00:00 app[web.1]: I, [2020-10-28T04:03:31.147670 #18] INFO -- : [2bf4683b-f3aa-479c-a58d-8a07ccb733d5] Rendering user_mailer/account_activation.html.erb within layouts/mailer 2020-10-28T04:03:31.153533+00:00 app[web.1]: I, [2020-10-28T04:03:31.153410 #18] INFO -- : [2bf4683b-f3aa-479c-a58d-8a07ccb733d5] Rendered user_mailer/account_activation.html.erb within layouts/mailer (Duration: 5.5ms | Allocations: 195) 2020-10-28T04:03:31.154865+00:00 app[web.1]: I, [2020-10-28T04:03:31.154789 #18] INFO -- : [2bf4683b-f3aa-479c-a58d-8a07ccb733d5] Rendering user_mailer/account_activation.text.erb within layouts/mailer 2020-10-28T04:03:31.155656+00:00 app[web.1]: I, [2020-10-28T04:03:31.155578 #18] INFO -- : [2bf4683b-f3aa-479c-a58d-8a07ccb733d5] Rendered user_mailer/account_activation.text.erb within layouts/mailer (Duration: 0.7ms | Allocations: 182) 2020-10-28T04:03:31.161921+00:00 app[web.1]: D, [2020-10-28T04:03:31.161802 #18] DEBUG -- : [2bf4683b-f3aa-479c-a58d-8a07ccb733d5] UserMailer#account_activation: processed outbound mail in 18.7ms 2020-10-28T04:03:31.449681+00:00 app[web.1]: I, [2020-10-28T04:03:31.449480 #18] INFO -- : [2bf4683b-f3aa-479c-a58d-8a07ccb733d5] Delivered mail 5f98ed93282cb_122b204041a44849b1@05a0be7c-1941-44de-af3e-4b42c87222ba.mail (287.3ms) 2020-10-28T04:03:31.449769+00:00 app[web.1]: D, [2020-10-28T04:03:31.449685 #18] DEBUG -- : [2bf4683b-f3aa-479c-a58d-8a07ccb733d5] Date: Wed, 28 Oct 2020 04:03:31 +0000 2020-10-28T04:03:31.449770+00:00 app[web.1]: From: noreply@example.com 2020-10-28T04:03:31.449770+00:00 app[web.1]: To: harasou41soccer@gmail.commmmm 2020-10-28T04:03:31.449771+00:00 app[web.1]: Message-ID: <5f98ed93282cb_122b204041a44849b1@05a0be7c-1941-44de-af3e-4b42c87222ba.mail> 2020-10-28T04:03:31.449772+00:00 app[web.1]: Subject: Account activation 2020-10-28T04:03:31.449772+00:00 app[web.1]: Mime-Version: 1.0 2020-10-28T04:03:31.449773+00:00 app[web.1]: Content-Type: multipart/alternative; 2020-10-28T04:03:31.449773+00:00 app[web.1]: boundary="--==_mimepart_5f98ed9326da4_122b204041a44848d9"; 2020-10-28T04:03:31.449774+00:00 app[web.1]: charset=UTF-8 2020-10-28T04:03:31.449774+00:00 app[web.1]: Content-Transfer-Encoding: 7bit 2020-10-28T04:03:31.449775+00:00 app[web.1]: 2020-10-28T04:03:31.449775+00:00 app[web.1]: 2020-10-28T04:03:31.449775+00:00 app[web.1]: ----==_mimepart_5f98ed9326da4_122b204041a44848d9 2020-10-28T04:03:31.449776+00:00 app[web.1]: Content-Type: text/plain; 2020-10-28T04:03:31.449776+00:00 app[web.1]: charset=UTF-8 2020-10-28T04:03:31.449776+00:00 app[web.1]: Content-Transfer-Encoding: quoted-printable 2020-10-28T04:03:31.449777+00:00 app[web.1]: 2020-10-28T04:03:31.449777+00:00 app[web.1]: =0D 2020-10-28T04:03:31.449778+00:00 app[web.1]: Hi =E3=81=9D=E3=81=86=E3=81=A1=E3=82=83=E3=82=93,=0D 2020-10-28T04:03:31.449778+00:00 app[web.1]: =0D 2020-10-28T04:03:31.449779+00:00 app[web.1]: Welcome to the Sample App! Click on the link below to activate your accou= 2020-10-28T04:03:31.449779+00:00 app[web.1]: nt:=0D 2020-10-28T04:03:31.449779+00:00 app[web.1]: =0D 2020-10-28T04:03:31.449780+00:00 app[web.1]: https://harasou-rails-tutorial.herokuapp.com/account_activations/76_-OF0U= 2020-10-28T04:03:31.449780+00:00 app[web.1]: RzNnZ-fq83jfmw/edit?email=3Dharasou41soccer%40gmail.commmmm=0D 2020-10-28T04:03:31.449780+00:00 app[web.1]: =0D 2020-10-28T04:03:31.449781+00:00 app[web.1]: 2020-10-28T04:03:31.449781+00:00 app[web.1]: ----==_mimepart_5f98ed9326da4_122b204041a44848d9 2020-10-28T04:03:31.449781+00:00 app[web.1]: Content-Type: text/html; 2020-10-28T04:03:31.449782+00:00 app[web.1]: charset=UTF-8 2020-10-28T04:03:31.449782+00:00 app[web.1]: Content-Transfer-Encoding: quoted-printable 2020-10-28T04:03:31.449783+00:00 app[web.1]: 2020-10-28T04:03:31.449783+00:00 app[web.1]: <!DOCTYPE html>=0D 2020-10-28T04:03:31.449784+00:00 app[web.1]: <html>=0D 2020-10-28T04:03:31.449784+00:00 app[web.1]: <head>=0D 2020-10-28T04:03:31.449784+00:00 app[web.1]: <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf= 2020-10-28T04:03:31.449785+00:00 app[web.1]: -8" />=0D 2020-10-28T04:03:31.449785+00:00 app[web.1]: <style>=0D 2020-10-28T04:03:31.449785+00:00 app[web.1]: /* Email styles need to be inline */=0D 2020-10-28T04:03:31.449786+00:00 app[web.1]: </style>=0D 2020-10-28T04:03:31.449786+00:00 app[web.1]: </head>=0D 2020-10-28T04:03:31.449786+00:00 app[web.1]: =0D 2020-10-28T04:03:31.449787+00:00 app[web.1]: <body>=0D 2020-10-28T04:03:31.449787+00:00 app[web.1]: <h1>Sample App</h1>=0D 2020-10-28T04:03:31.449788+00:00 app[web.1]: =0D 2020-10-28T04:03:31.449788+00:00 app[web.1]: <p>Hi =E3=81=9D=E3=81=86=E3=81=A1=E3=82=83=E3=82=93,</p>=0D 2020-10-28T04:03:31.449788+00:00 app[web.1]: =0D 2020-10-28T04:03:31.449788+00:00 app[web.1]: <p>=0D 2020-10-28T04:03:31.449789+00:00 app[web.1]: Welcome to the Sample App! Click on the link below to activate your accou= 2020-10-28T04:03:31.449789+00:00 app[web.1]: nt:=0D 2020-10-28T04:03:31.449789+00:00 app[web.1]: </p>=0D 2020-10-28T04:03:31.449790+00:00 app[web.1]: =0D 2020-10-28T04:03:31.449790+00:00 app[web.1]: <a href=3D"https://harasou-rails-tutorial.herokuapp.com/account_activatio= 2020-10-28T04:03:31.449790+00:00 app[web.1]: ns/76_-OF0URzNnZ-fq83jfmw/edit?email=3Dhcr%40gmail.commmmm">A= 2020-10-28T04:03:31.449791+00:00 app[web.1]: ctivate</a>=0D 2020-10-28T04:03:31.449791+00:00 app[web.1]: </body>=0D 2020-10-28T04:03:31.449791+00:00 app[web.1]: </html>=0D 2020-10-28T04:03:31.449791+00:00 app[web.1]: 2020-10-28T04:03:31.449792+00:00 app[web.1]: ----==_mimepart_5f98ed9326da4_122b204041a44848d9-- 2020-10-28T04:03:31.449792+00:00 app[web.1]: 2020-10-28T04:03:31.450189+00:00 app[web.1]: I, [2020-10-28T04:03:31.450111 #18] INFO -- : [2bf4683b-f3aa-479c-a58d-8a07ccb733d5] Completed 500 Internal Server Error in 1051ms (ActiveRecord: 7.9ms | Allocations: 6375) 2020-10-28T04:03:31.451544+00:00 app[web.1]: F, [2020-10-28T04:03:31.451465 #18] FATAL -- : [2bf4683b-f3aa-479c-a58d-8a07ccb733d5] 2020-10-28T04:03:31.451545+00:00 app[web.1]: [2bf4683b-f3aa-479c-a58d-8a07ccb733d5] Net::SMTPAuthenticationError (535 Authentication failed: account disabled 2020-10-28T04:03:31.451545+00:00 app[web.1]: ): 2020-10-28T04:03:31.451546+00:00 app[web.1]: [2bf4683b-f3aa-479c-a58d-8a07ccb733d5] 2020-10-28T04:03:31.451546+00:00 app[web.1]: [2bf4683b-f3aa-479c-a58d-8a07ccb733d5] app/models/user.rb:71:in `send_activation_email' 2020-10-28T04:03:31.451547+00:00 app[web.1]: [2bf4683b-f3aa-479c-a58d-8a07ccb733d5] app/controllers/users_controller.rb:30:in `create' 2020-10-28T04:03:31.465527+00:00 heroku[router]: at=info method=POST path="/users" host=harasou-rails-tutorial.herokuapp.com request_id=2bf4683b-f3aa-479c-a58d-8a07ccb733d5 fwd="126.163.133.25" dyno=web.1 connect=1ms service=1064ms status=500 bytes=1891 protocol=https
production.rb
ruby
1 config.action_mailer.raise_delivery_errors = true 2 config.action_mailer.delivery_method = :smtp 3 host = 'harasou-rails-tutorial.herokuapp.com' 4 config.action_mailer.default_url_options = { host: host } 5 ActionMailer::Base.smtp_settings = { 6 :address => 'smtp.sendgrid.net', 7 :port => '587', 8 :authentication => :plain, 9 :user_name => ENV['SENDGRID_USERNAME'], 10 :password => ENV['SENDGRID_PASSWORD'], 11 :domain => 'heroku.com', 12 :enable_starttls_auto => true 13 }
環境変数が設定できてないのかと思い、環境変数を設定しました
heroku config で確認したところしっかり設定できたように思えます。
開発環境では上手く行ったので、環境変数だけの問題に思えましたが、、、上手くいきませんでした。
heroku addons:create sendgrid:starter
ももちろんやりました
cloud9
rails 6.0.0
ruby 2.6.3
あなたの回答
tips
プレビュー