Heroku 环境中的 Ruby on Rails 应用程序:“使用 Mailgun 发送电子邮件”错误

Posted

技术标签:

【中文标题】Heroku 环境中的 Ruby on Rails 应用程序:“使用 Mailgun 发送电子邮件”错误【英文标题】:Ruby on Rails app on a Heroku environment: "Sending Email with Mailgun" error 【发布时间】:2017-07-15 20:06:17 【问题描述】:

我试图测试从基于 Heroku 服务器的 Rails 应用程序的联系表单发送电子邮件,我收到一条错误消息:

很抱歉,出了点问题。如果您是应用程序所有者,请查看日志以获取更多信息。

我的目的是学习如何将邮件服务器服务集成到我的 Heroku 帐户中。为此,使用的插件是 MailGun。我什至用我的个人电子邮件创建了一个 MailGun 帐户,以便能够检查我是否收到了电子邮件。

在成功将代码从 Cloud9 环境部署到 Heroku 服务器后,我对 Ruby 代码所做的唯一更改是以下内容:

config/environment.rb

ActionMailer::Base.smtp_settings = 
  :port           => ENV['MAILGUN_SMTP_PORT'],
  :address        => ENV['MAILGUN_SMTP_SERVER'],
  :user_name      => ENV['MAILGUN_SMTP_LOGIN'],
  :password       => ENV['MAILGUN_SMTP_PASSWORD'],
  :domain         => 'blahblahblah.herokuapp.com',
  :authentication => :plain,

ActionMailer::Base.delivery_method = :smtp

有什么问题?有什么解决办法吗?

更新的请求信息(Heroku 日志 - 由于 *** 正文中的字符限制,我无法更新所有日志):

iamsamuel:~/workspace/saasapp (master) $ heroku logs
2017-02-24T20:18:19.316716+00:00 app[web.1]: Content-Type: text/html;
2017-02-24T20:18:19.316717+00:00 app[web.1]:  charset=UTF-8
2017-02-24T20:18:19.316718+00:00 app[web.1]: Content-Transfer-Encoding: 7bit
2017-02-24T20:18:19.316718+00:00 app[web.1]:
2017-02-24T20:18:19.316719+00:00 app[web.1]: <!DOCTYPE html>
2017-02-24T20:18:19.316719+00:00 app[web.1]: <html>
2017-02-24T20:18:19.316720+00:00 app[web.1]:     <head>
2017-02-24T20:18:19.316721+00:00 app[web.1]:     </head>
2017-02-24T20:18:19.316721+00:00 app[web.1]:     <body>
2017-02-24T20:18:19.316722+00:00 app[web.1]:         <p>
2017-02-24T20:18:19.316723+00:00 app[web.1]:             You have received a message from the site's contact form, from Sam, smlmrr@outlook.com.
2017-02-24T20:18:19.316724+00:00 app[web.1]:         </p>
2017-02-24T20:18:19.316724+00:00 app[web.1]:         <p>
2017-02-24T20:18:19.316725+00:00 app[web.1]:
2017-02-24T20:18:19.316725+00:00 app[web.1]:         </p>
2017-02-24T20:18:19.316726+00:00 app[web.1]:     </body>
2017-02-24T20:18:19.316726+00:00 app[web.1]: </html>
2017-02-24T20:18:19.316886+00:00 app[web.1]: I, [2017-02-24T20:18:19.316838 #4]  INFO -- : [f024cbfb-df8b-4efa-8cb1-50a6a0d7881c] Completed 500 Internal Server Error in 1166ms (ActiveRecord: 4.1ms)
2017-02-24T20:18:19.317316+00:00 app[web.1]: F, [2017-02-24T20:18:19.317273 #4] FATAL -- : [f024cbfb-df8b-4efa-8cb1-50a6a0d7881c]
2017-02-24T20:18:19.317357+00:00 app[web.1]: F, [2017-02-24T20:18:19.317318 #4] FATAL -- : [f024cbfb-df8b-4efa-8cb1-50a6a0d7881c] Net::SMTPFatalError (554 Please activate your Mailgun account. Check your inbox or log in to your control panel to resend the activation email.
2017-02-24T20:18:19.317358+00:00 app[web.1]: ):
2017-02-24T20:18:19.317396+00:00 app[web.1]: F, [2017-02-24T20:18:19.317355 #4] FATAL -- : [f024cbfb-df8b-4efa-8cb1-50a6a0d7881c]
2017-02-24T20:18:19.317435+00:00 app[web.1]: F, [2017-02-24T20:18:19.317396 #4] FATAL -- : [f024cbfb-df8b-4efa-8cb1-50a6a0d7881c] app/controllers/contacts_controller.rb:15:in `create'
2017-02-24T20:18:19.520898+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=infinite-forest-28304.herokuapp.com request_id=62153ff0-bef7-4e44-958b-447fb18e7c23 fwd="188.83.235.112" dyno=web.1 connect=0ms service=1ms status=304 bytes=48
2017-02-24T20:53:16.169251+00:00 heroku[web.1]: Idling
2017-02-24T20:53:16.169901+00:00 heroku[web.1]: State changed from up to down
2017-02-24T20:53:17.034264+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-02-24T20:53:17.078764+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2017-02-24T20:53:17.078952+00:00 app[web.1]: === puma shutdown: 2017-02-24 20:53:17 +0000 ===
2017-02-24T20:53:17.078957+00:00 app[web.1]: - Goodbye!
2017-02-24T20:53:17.079100+00:00 app[web.1]: Exiting
2017-02-24T20:53:17.347515+00:00 heroku[web.1]: Process exited with status 0
2017-02-24T20:57:24.680979+00:00 heroku[web.1]: Unidling
2017-02-24T20:57:24.681258+00:00 heroku[web.1]: State changed from down to starting
2017-02-24T20:57:27.221989+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 44473 -e production`
2017-02-24T20:57:30.299354+00:00 app[web.1]: => Booting Puma
2017-02-24T20:57:30.299447+00:00 app[web.1]: => Rails 5.0.0 application starting in production on http://0.0.0.0:44473
2017-02-24T20:57:30.299502+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-02-24T20:57:31.229688+00:00 app[web.1]: Puma starting in single mode...
2017-02-24T20:57:31.229714+00:00 app[web.1]: * Min threads: 5, max threads: 5
2017-02-24T20:57:31.229713+00:00 app[web.1]: * Version 3.4.0 (ruby 2.3.0-p0), codename: Owl Bowl Brawl
2017-02-24T20:57:31.229716+00:00 app[web.1]: * Environment: production
2017-02-24T20:57:31.229813+00:00 app[web.1]: * Listening on tcp://0.0.0.0:44473
2017-02-24T20:57:31.230029+00:00 app[web.1]: Use Ctrl-C to stop
2017-02-24T20:57:31.421917+00:00 heroku[web.1]: State changed from starting to up
2017-02-24T20:57:32.788592+00:00 heroku[router]: at=info method=GET path="/" host=infinite-forest-28304.herokuapp.com request_id=dedd394a-498a-464d-a669-ed19fa2fd418 fwd="188.83.235.112" dyno=web.1 connect=0ms service=58ms status=200 bytes=2753
2017-02-24T20:57:32.737531+00:00 app[web.1]: I, [2017-02-24T20:57:32.737424 #4]  INFO -- : [dedd394a-498a-464d-a669-ed19fa2fd418] Started GET "/" for 188.83.235.112 at 2017-02-24 20:57:32 +0000
2017-02-24T20:57:32.740219+00:00 app[web.1]: I, [2017-02-24T20:57:32.740152 #4]  INFO -- : [dedd394a-498a-464d-a669-ed19fa2fd418] Processing by PagesController#home as HTML
2017-02-24T20:57:32.752357+00:00 app[web.1]: I, [2017-02-24T20:57:32.752273 #4]  INFO -- : [dedd394a-498a-464d-a669-ed19fa2fd418]   Rendering pages/home.html.erb within layouts/application
2017-02-24T20:57:32.753153+00:00 app[web.1]: I, [2017-02-24T20:57:32.753082 #4]  INFO -- : [dedd394a-498a-464d-a669-ed19fa2fd418]   Rendered pages/home.html.erb within layouts/application (0.6ms)
2017-02-24T20:57:32.759595+00:00 app[web.1]: I, [2017-02-24T20:57:32.759524 #4]  INFO -- : [dedd394a-498a-464d-a669-ed19fa2fd418] Completed 200 OK in 19ms (Views: 8.6ms | ActiveRecord: 0.0ms)
2017-02-24T20:57:32.929609+00:00 heroku[router]: at=info method=GET path="/assets/application-95163fa38446d1bb6139f870d5fb932af7fa47b347b8951923c32a4565386aa6.js" host=infinite-forest-28304.herokuapp.com request_id=80d55a95-cbe8-4982-a571-bc8850567a87 fwd="188.83.235.112" dyno=web.1 connect=0ms service=1ms status=304 bytes=48
2017-02-24T20:57:32.928158+00:00 heroku[router]: at=info method=GET path="/assets/application-5ed627eba0abe94ba4e2c255c2298f55d9bca9b4ea45ded59ba1705edc5385d0.css" host=infinite-forest-28304.herokuapp.com request_id=a9c456f3-e7cd-4d6a-865f-2c8f5efbdaa7 fwd="188.83.235.112" dyno=web.1 connect=0ms service=1ms status=304 bytes=48
2017-02-24T20:57:33.143930+00:00 heroku[router]: at=info method=GET path="/assets/font-awesome/fontawesome-webfont-2932abf996373e87fbf2e950876b1962f1b57db954a1643ea68831d9fbb74da4.woff2?v=4.6.2" host=infinite-forest-28304.herokuapp.com request_id=90d78563-eaa6-4f24-a054-5c89beada59c fwd="188.83.235.112" dyno=web.1 connect=3ms service=1ms status=304 bytes=48
2017-02-24T20:57:33.402193+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=infinite-forest-28304.herokuapp.com request_id=7c20311c-bd5a-46c3-a9d5-c6266c1f9331 fwd="188.83.235.112" dyno=web.1 connect=0ms service=1ms status=304 bytes=48
2017-02-24T20:57:50.706814+00:00 heroku[router]: at=info method=GET path="/contact-us" host=infinite-forest-28304.herokuapp.com request_id=0ec752b1-0d75-42dd-83f6-ecd127086bfb fwd="188.83.235.112" dyno=web.1 connect=0ms service=35ms status=200 bytes=4317
2017-02-24T20:57:50.651067+00:00 app[web.1]: I, [2017-02-24T20:57:50.650984 #4]  INFO -- : [0ec752b1-0d75-42dd-83f6-ecd127086bfb] Started GET "/contact-us" for 188.83.235.112 at 2017-02-24 20:57:50 +0000
2017-02-24T20:57:50.652579+00:00 app[web.1]: I, [2017-02-24T20:57:50.652518 #4]  INFO -- : [0ec752b1-0d75-42dd-83f6-ecd127086bfb] Processing by ContactsController#new as HTML
2017-02-24T20:57:50.669618+00:00 app[web.1]: I, [2017-02-24T20:57:50.669536 #4]  INFO -- : [0ec752b1-0d75-42dd-83f6-ecd127086bfb]   Rendering contacts/new.html.erb within layouts/application
2017-02-24T20:57:50.681558+00:00 app[web.1]: I, [2017-02-24T20:57:50.681481 #4]  INFO -- : [0ec752b1-0d75-42dd-83f6-ecd127086bfb]   Rendered contacts/new.html.erb within layouts/application (11.8ms)
2017-02-24T20:57:50.682909+00:00 app[web.1]: I, [2017-02-24T20:57:50.682846 #4]  INFO -- : [0ec752b1-0d75-42dd-83f6-ecd127086bfb] Completed 200 OK in 30ms (Views: 14.0ms | ActiveRecord: 7.5ms)
2017-02-24T20:59:14.426470+00:00 app[web.1]: I, [2017-02-24T20:59:14.426395 #4]  INFO -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6] Started POST "/contacts" for 188.83.235.112 at 2017-02-24 20:59:14 +0000
2017-02-24T20:59:14.427281+00:00 app[web.1]: I, [2017-02-24T20:59:14.427232 #4]  INFO -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6] Processing by ContactsController#create as HTML
2017-02-24T20:59:14.427366+00:00 app[web.1]: I, [2017-02-24T20:59:14.427324 #4]  INFO -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6]   Parameters: "utf8"=>"✓", "authenticity_token"=>"MgrtXM/8aUAYPnJ2ph4eIbsqMbLR/xXMZabcKmKh4myMlp0MdLJ2dCHnh7KshXSCqAsIzGQr0SdebpJw1v0QHw==", "contact"=>"name"=>"Jesse Pinkman", "email"=>"jp@example.com", "comments"=>"Yo Beach!", "commit"=>"Submit"
2017-02-24T20:59:14.429694+00:00 app[web.1]: D, [2017-02-24T20:59:14.429641 #4] DEBUG -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6]    (0.9ms)  BEGIN
2017-02-24T20:59:14.434537+00:00 app[web.1]: D, [2017-02-24T20:59:14.434485 #4] DEBUG -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6]   SQL (1.3ms)  INSERT INTO "contacts" ("name", "email", "comments", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id"  [["name", "Jesse Pinkman"], ["email", "jp@example.com"], ["comments", "Yo Beach!"], ["created_at", 2017-02-24 20:59:14 UTC], ["updated_at", 2017-02-24 20:59:14 UTC]]
2017-02-24T20:59:14.436712+00:00 app[web.1]: D, [2017-02-24T20:59:14.436665 #4] DEBUG -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6]    (1.9ms)  COMMIT
2017-02-24T20:59:14.441776+00:00 app[web.1]: I, [2017-02-24T20:59:14.441724 #4]  INFO -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6]   Rendering contact_mailer/contact_email.html.erb
2017-02-24T20:59:14.442284+00:00 app[web.1]: I, [2017-02-24T20:59:14.442237 #4]  INFO -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6]   Rendered contact_mailer/contact_email.html.erb (0.4ms)
2017-02-24T20:59:14.622612+00:00 app[web.1]: D, [2017-02-24T20:59:14.622518 #4] DEBUG -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6] ContactMailer#contact_email: processed outbound mail in 184.5ms
2017-02-24T20:59:14.749027+00:00 heroku[router]: at=info method=POST path="/contacts" host=infinite-forest-28304.herokuapp.com request_id=606794a4-3f9b-417c-b3ca-72af4d8bafb6 fwd="188.83.235.112" dyno=web.1 connect=0ms service=304ms status=500 bytes=1669
2017-02-24T20:59:14.722589+00:00 app[web.1]: I, [2017-02-24T20:59:14.722491 #4]  INFO -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6] Sent mail to samuelslmoreira@hotmail.com (99.8ms)
2017-02-24T20:59:14.722632+00:00 app[web.1]: D, [2017-02-24T20:59:14.722588 #4] DEBUG -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6] Date: Fri, 24 Feb 2017 20:59:14 +0000
2017-02-24T20:59:14.722632+00:00 app[web.1]: From: jp@example.com
2017-02-24T20:59:14.722633+00:00 app[web.1]: To: samuelslmoreira@hotmail.com
2017-02-24T20:59:14.722633+00:00 app[web.1]: Message-ID: <58b09ea298a14_43fc0c75eb9c0103ae@71798652-2827-4935-9282-6b3ae7c47b44.mail>
2017-02-24T20:59:14.722634+00:00 app[web.1]: Subject: Contact Form Message
2017-02-24T20:59:14.722634+00:00 app[web.1]: Mime-Version: 1.0
2017-02-24T20:59:14.722635+00:00 app[web.1]: Content-Type: text/html;
2017-02-24T20:59:14.722635+00:00 app[web.1]:  charset=UTF-8
2017-02-24T20:59:14.722635+00:00 app[web.1]: Content-Transfer-Encoding: 7bit
2017-02-24T20:59:14.722636+00:00 app[web.1]:
2017-02-24T20:59:14.722636+00:00 app[web.1]: <!DOCTYPE html>
2017-02-24T20:59:14.722637+00:00 app[web.1]: <html>
2017-02-24T20:59:14.722637+00:00 app[web.1]:     <head>
2017-02-24T20:59:14.722637+00:00 app[web.1]:     </head>
2017-02-24T20:59:14.722638+00:00 app[web.1]:     <body>
2017-02-24T20:59:14.722638+00:00 app[web.1]:         <p>
2017-02-24T20:59:14.722638+00:00 app[web.1]:             You have received a message from the site's contact form, from Jesse Pinkman, jp@example.com.
2017-02-24T20:59:14.722639+00:00 app[web.1]:         </p>
2017-02-24T20:59:14.722639+00:00 app[web.1]:         <p>
2017-02-24T20:59:14.722639+00:00 app[web.1]:
2017-02-24T20:59:14.722640+00:00 app[web.1]:         </p>
2017-02-24T20:59:14.722640+00:00 app[web.1]:     </body>
2017-02-24T20:59:14.722640+00:00 app[web.1]: </html>
2017-02-24T20:59:14.722825+00:00 app[web.1]: I, [2017-02-24T20:59:14.722779 #4]  INFO -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6] Completed 500 Internal Server Error in 295ms (ActiveRecord: 4.1ms)
2017-02-24T20:59:14.723286+00:00 app[web.1]: F, [2017-02-24T20:59:14.723242 #4] FATAL -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6]
2017-02-24T20:59:14.723324+00:00 app[web.1]: F, [2017-02-24T20:59:14.723287 #4] FATAL -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6] Net::SMTPFatalError (554 Please activate your Mailgun account. Check your inbox or log in to your control panel to resend the activation email.
2017-02-24T20:59:14.723325+00:00 app[web.1]: ):
2017-02-24T20:59:14.723357+00:00 app[web.1]: F, [2017-02-24T20:59:14.723324 #4] FATAL -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6]
2017-02-24T20:59:14.723390+00:00 app[web.1]: F, [2017-02-24T20:59:14.723357 #4] FATAL -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6] app/controllers/contacts_controller.rb:15:in `create'
iamsamuel:~/workspace/saasapp (master) $ clear
iamsamuel:~/workspace/saasapp (master) $ clear
iamsamuel:~/workspace/saasapp (master) $ heroku logs
2017-02-24T20:18:19.316723+00:00 app[web.1]:             You have received a message from the site's contact form, from Sam, smlmrr@outlook.com.
2017-02-24T20:18:19.316724+00:00 app[web.1]:         </p>
2017-02-24T20:18:19.316724+00:00 app[web.1]:         <p>
2017-02-24T20:18:19.316725+00:00 app[web.1]:             
2017-02-24T20:18:19.316725+00:00 app[web.1]:         </p>
2017-02-24T20:18:19.316726+00:00 app[web.1]:     </body>
2017-02-24T20:18:19.316726+00:00 app[web.1]: </html>
2017-02-24T20:18:19.316886+00:00 app[web.1]: I, [2017-02-24T20:18:19.316838 #4]  INFO -- : [f024cbfb-df8b-4efa-8cb1-50a6a0d7881c] Completed 500 Internal Server Error in 1166ms (ActiveRecord: 4.1ms)
2017-02-24T20:18:19.317316+00:00 app[web.1]: F, [2017-02-24T20:18:19.317273 #4] FATAL -- : [f024cbfb-df8b-4efa-8cb1-50a6a0d7881c]   
2017-02-24T20:18:19.317357+00:00 app[web.1]: F, [2017-02-24T20:18:19.317318 #4] FATAL -- : [f024cbfb-df8b-4efa-8cb1-50a6a0d7881c] Net::SMTPFatalError (554 Please activate your Mailgun account. Check your inbox or log in to your control panel to resend the activation email.
2017-02-24T20:18:19.317358+00:00 app[web.1]: ):
2017-02-24T20:18:19.317396+00:00 app[web.1]: F, [2017-02-24T20:18:19.317355 #4] FATAL -- : [f024cbfb-df8b-4efa-8cb1-50a6a0d7881c]   
2017-02-24T20:18:19.317435+00:00 app[web.1]: F, [2017-02-24T20:18:19.317396 #4] FATAL -- : [f024cbfb-df8b-4efa-8cb1-50a6a0d7881c] app/controllers/contacts_controller.rb:15:in `create'
2017-02-24T20:18:19.520898+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=infinite-forest-28304.herokuapp.com request_id=62153ff0-bef7-4e44-958b-447fb18e7c23 fwd="188.83.235.112" dyno=web.1 connect=0ms service=1ms status=304 bytes=48
2017-02-24T20:53:16.169251+00:00 heroku[web.1]: Idling
2017-02-24T20:53:16.169901+00:00 heroku[web.1]: State changed from up to down
2017-02-24T20:53:17.034264+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-02-24T20:53:17.078764+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2017-02-24T20:53:17.078952+00:00 app[web.1]: === puma shutdown: 2017-02-24 20:53:17 +0000 ===
2017-02-24T20:53:17.078957+00:00 app[web.1]: - Goodbye!
2017-02-24T20:53:17.079100+00:00 app[web.1]: Exiting
2017-02-24T20:53:17.347515+00:00 heroku[web.1]: Process exited with status 0
2017-02-24T20:57:24.680979+00:00 heroku[web.1]: Unidling
2017-02-24T20:57:24.681258+00:00 heroku[web.1]: State changed from down to starting
2017-02-24T20:57:27.221989+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 44473 -e production`
2017-02-24T20:57:30.299354+00:00 app[web.1]: => Booting Puma
2017-02-24T20:57:30.299447+00:00 app[web.1]: => Rails 5.0.0 application starting in production on http://0.0.0.0:44473
2017-02-24T20:57:30.299502+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-02-24T20:57:31.229688+00:00 app[web.1]: Puma starting in single mode...
2017-02-24T20:57:31.229714+00:00 app[web.1]: * Min threads: 5, max threads: 5
2017-02-24T20:57:31.229713+00:00 app[web.1]: * Version 3.4.0 (ruby 2.3.0-p0), codename: Owl Bowl Brawl
2017-02-24T20:57:31.229716+00:00 app[web.1]: * Environment: production
2017-02-24T20:57:31.229813+00:00 app[web.1]: * Listening on tcp://0.0.0.0:44473
2017-02-24T20:57:31.230029+00:00 app[web.1]: Use Ctrl-C to stop
2017-02-24T20:57:31.421917+00:00 heroku[web.1]: State changed from starting to up
2017-02-24T20:57:32.788592+00:00 heroku[router]: at=info method=GET path="/" host=infinite-forest-28304.herokuapp.com request_id=dedd394a-498a-464d-a669-ed19fa2fd418 fwd="188.83.235.112" dyno=web.1 connect=0ms service=58ms status=200 bytes=2753
2017-02-24T20:57:32.737531+00:00 app[web.1]: I, [2017-02-24T20:57:32.737424 #4]  INFO -- : [dedd394a-498a-464d-a669-ed19fa2fd418] Started GET "/" for 188.83.235.112 at 2017-02-24 20:57:32 +0000
2017-02-24T20:57:32.740219+00:00 app[web.1]: I, [2017-02-24T20:57:32.740152 #4]  INFO -- : [dedd394a-498a-464d-a669-ed19fa2fd418] Processing by PagesController#home as HTML
2017-02-24T20:57:32.752357+00:00 app[web.1]: I, [2017-02-24T20:57:32.752273 #4]  INFO -- : [dedd394a-498a-464d-a669-ed19fa2fd418]   Rendering pages/home.html.erb within layouts/application
2017-02-24T20:57:32.753153+00:00 app[web.1]: I, [2017-02-24T20:57:32.753082 #4]  INFO -- : [dedd394a-498a-464d-a669-ed19fa2fd418]   Rendered pages/home.html.erb within layouts/application (0.6ms)
2017-02-24T20:57:32.759595+00:00 app[web.1]: I, [2017-02-24T20:57:32.759524 #4]  INFO -- : [dedd394a-498a-464d-a669-ed19fa2fd418] Completed 200 OK in 19ms (Views: 8.6ms | ActiveRecord: 0.0ms)
2017-02-24T20:57:32.929609+00:00 heroku[router]: at=info method=GET path="/assets/application-95163fa38446d1bb6139f870d5fb932af7fa47b347b8951923c32a4565386aa6.js" host=infinite-forest-28304.herokuapp.com request_id=80d55a95-cbe8-4982-a571-bc8850567a87 fwd="188.83.235.112" dyno=web.1 connect=0ms service=1ms status=304 bytes=48
2017-02-24T20:57:32.928158+00:00 heroku[router]: at=info method=GET path="/assets/application-5ed627eba0abe94ba4e2c255c2298f55d9bca9b4ea45ded59ba1705edc5385d0.css" host=infinite-forest-28304.herokuapp.com request_id=a9c456f3-e7cd-4d6a-865f-2c8f5efbdaa7 fwd="188.83.235.112" dyno=web.1 connect=0ms service=1ms status=304 bytes=48
2017-02-24T20:57:33.143930+00:00 heroku[router]: at=info method=GET path="/assets/font-awesome/fontawesome-webfont-2932abf996373e87fbf2e950876b1962f1b57db954a1643ea68831d9fbb74da4.woff2?v=4.6.2" host=infinite-forest-28304.herokuapp.com request_id=90d78563-eaa6-4f24-a054-5c89beada59c fwd="188.83.235.112" dyno=web.1 connect=3ms service=1ms status=304 bytes=48
2017-02-24T20:57:33.402193+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=infinite-forest-28304.herokuapp.com request_id=7c20311c-bd5a-46c3-a9d5-c6266c1f9331 fwd="188.83.235.112" dyno=web.1 connect=0ms service=1ms status=304 bytes=48
2017-02-24T20:57:50.706814+00:00 heroku[router]: at=info method=GET path="/contact-us" host=infinite-forest-28304.herokuapp.com request_id=0ec752b1-0d75-42dd-83f6-ecd127086bfb fwd="188.83.235.112" dyno=web.1 connect=0ms service=35ms status=200 bytes=4317
2017-02-24T20:57:50.651067+00:00 app[web.1]: I, [2017-02-24T20:57:50.650984 #4]  INFO -- : [0ec752b1-0d75-42dd-83f6-ecd127086bfb] Started GET "/contact-us" for 188.83.235.112 at 2017-02-24 20:57:50 +0000
2017-02-24T20:57:50.652579+00:00 app[web.1]: I, [2017-02-24T20:57:50.652518 #4]  INFO -- : [0ec752b1-0d75-42dd-83f6-ecd127086bfb] Processing by ContactsController#new as HTML
2017-02-24T20:57:50.669618+00:00 app[web.1]: I, [2017-02-24T20:57:50.669536 #4]  INFO -- : [0ec752b1-0d75-42dd-83f6-ecd127086bfb]   Rendering contacts/new.html.erb within layouts/application
2017-02-24T20:57:50.681558+00:00 app[web.1]: I, [2017-02-24T20:57:50.681481 #4]  INFO -- : [0ec752b1-0d75-42dd-83f6-ecd127086bfb]   Rendered contacts/new.html.erb within layouts/application (11.8ms)
2017-02-24T20:57:50.682909+00:00 app[web.1]: I, [2017-02-24T20:57:50.682846 #4]  INFO -- : [0ec752b1-0d75-42dd-83f6-ecd127086bfb] Completed 200 OK in 30ms (Views: 14.0ms | ActiveRecord: 7.5ms)
2017-02-24T20:59:14.426470+00:00 app[web.1]: I, [2017-02-24T20:59:14.426395 #4]  INFO -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6] Started POST "/contacts" for 188.83.235.112 at 2017-02-24 20:59:14 +0000
2017-02-24T20:59:14.427281+00:00 app[web.1]: I, [2017-02-24T20:59:14.427232 #4]  INFO -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6] Processing by ContactsController#create as HTML
2017-02-24T20:59:14.427366+00:00 app[web.1]: I, [2017-02-24T20:59:14.427324 #4]  INFO -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6]   Parameters: "utf8"=>"✓", "authenticity_token"=>"MgrtXM/8aUAYPnJ2ph4eIbsqMbLR/xXMZabcKmKh4myMlp0MdLJ2dCHnh7KshXSCqAsIzGQr0SdebpJw1v0QHw==", "contact"=>"name"=>"Jesse Pinkman", "email"=>"jp@example.com", "comments"=>"Yo Beach!", "commit"=>"Submit"
2017-02-24T20:59:14.429694+00:00 app[web.1]: D, [2017-02-24T20:59:14.429641 #4] DEBUG -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6]    (0.9ms)  BEGIN
2017-02-24T20:59:14.434537+00:00 app[web.1]: D, [2017-02-24T20:59:14.434485 #4] DEBUG -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6]   SQL (1.3ms)  INSERT INTO "contacts" ("name", "email", "comments", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id"  [["name", "Jesse Pinkman"], ["email", "jp@example.com"], ["comments", "Yo Beach!"], ["created_at", 2017-02-24 20:59:14 UTC], ["updated_at", 2017-02-24 20:59:14 UTC]]
2017-02-24T20:59:14.436712+00:00 app[web.1]: D, [2017-02-24T20:59:14.436665 #4] DEBUG -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6]    (1.9ms)  COMMIT
2017-02-24T20:59:14.441776+00:00 app[web.1]: I, [2017-02-24T20:59:14.441724 #4]  INFO -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6]   Rendering contact_mailer/contact_email.html.erb
2017-02-24T20:59:14.442284+00:00 app[web.1]: I, [2017-02-24T20:59:14.442237 #4]  INFO -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6]   Rendered contact_mailer/contact_email.html.erb (0.4ms)
2017-02-24T20:59:14.622612+00:00 app[web.1]: D, [2017-02-24T20:59:14.622518 #4] DEBUG -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6] ContactMailer#contact_email: processed outbound mail in 184.5ms
2017-02-24T20:59:14.749027+00:00 heroku[router]: at=info method=POST path="/contacts" host=infinite-forest-28304.herokuapp.com request_id=606794a4-3f9b-417c-b3ca-72af4d8bafb6 fwd="188.83.235.112" dyno=web.1 connect=0ms service=304ms status=500 bytes=1669
2017-02-24T20:59:14.722589+00:00 app[web.1]: I, [2017-02-24T20:59:14.722491 #4]  INFO -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6] Sent mail to samuelslmoreira@hotmail.com (99.8ms)
2017-02-24T20:59:14.722632+00:00 app[web.1]: D, [2017-02-24T20:59:14.722588 #4] DEBUG -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6] Date: Fri, 24 Feb 2017 20:59:14 +0000
2017-02-24T20:59:14.722632+00:00 app[web.1]: From: jp@example.com
2017-02-24T20:59:14.722633+00:00 app[web.1]: To: samuelslmoreira@hotmail.com
2017-02-24T20:59:14.722633+00:00 app[web.1]: Message-ID: <58b09ea298a14_43fc0c75eb9c0103ae@71798652-2827-4935-9282-6b3ae7c47b44.mail>
2017-02-24T20:59:14.722634+00:00 app[web.1]: Subject: Contact Form Message
2017-02-24T20:59:14.722634+00:00 app[web.1]: Mime-Version: 1.0
2017-02-24T20:59:14.722635+00:00 app[web.1]: Content-Type: text/html;
2017-02-24T20:59:14.722635+00:00 app[web.1]:  charset=UTF-8
2017-02-24T20:59:14.722635+00:00 app[web.1]: Content-Transfer-Encoding: 7bit
2017-02-24T20:59:14.722636+00:00 app[web.1]: 
2017-02-24T20:59:14.722636+00:00 app[web.1]: <!DOCTYPE html>
2017-02-24T20:59:14.722637+00:00 app[web.1]: <html>
2017-02-24T20:59:14.722637+00:00 app[web.1]:     <head>
2017-02-24T20:59:14.722637+00:00 app[web.1]:     </head>
2017-02-24T20:59:14.722638+00:00 app[web.1]:     <body>
2017-02-24T20:59:14.722638+00:00 app[web.1]:         <p>
2017-02-24T20:59:14.722638+00:00 app[web.1]:             You have received a message from the site's contact form, from Jesse Pinkman, jp@example.com.
2017-02-24T20:59:14.722639+00:00 app[web.1]:         </p>
2017-02-24T20:59:14.722639+00:00 app[web.1]:         <p>
2017-02-24T20:59:14.722639+00:00 app[web.1]:             
2017-02-24T20:59:14.722640+00:00 app[web.1]:         </p>
2017-02-24T20:59:14.722640+00:00 app[web.1]:     </body>
2017-02-24T20:59:14.722640+00:00 app[web.1]: </html>
2017-02-24T20:59:14.722825+00:00 app[web.1]: I, [2017-02-24T20:59:14.722779 #4]  INFO -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6] Completed 500 Internal Server Error in 295ms (ActiveRecord: 4.1ms)
2017-02-24T20:59:14.723286+00:00 app[web.1]: F, [2017-02-24T20:59:14.723242 #4] FATAL -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6]   
2017-02-24T20:59:14.723324+00:00 app[web.1]: F, [2017-02-24T20:59:14.723287 #4] FATAL -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6] Net::SMTPFatalError (554 Please activate your Mailgun account. Check your inbox or log in to your control panel to resend the activation email.
2017-02-24T20:59:14.723325+00:00 app[web.1]: ):
2017-02-24T20:59:14.723357+00:00 app[web.1]: F, [2017-02-24T20:59:14.723324 #4] FATAL -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6]   
2017-02-24T20:59:14.723390+00:00 app[web.1]: F, [2017-02-24T20:59:14.723357 #4] FATAL -- : [606794a4-3f9b-417c-b3ca-72af4d8bafb6] app/controllers/contacts_controller.rb:15:in `create'
2017-02-24T21:30:27.890702+00:00 heroku[router]: at=info method=GET path="/" host=infinite-forest-28304.herokuapp.com request_id=ef1e2185-e94e-4a90-907e-15dad519fd59 fwd="188.83.235.112" dyno=web.1 connect=1ms service=6ms status=200 bytes=2753
2017-02-24T21:30:27.866291+00:00 app[web.1]: I, [2017-02-24T21:30:27.866202 #4]  INFO -- : [ef1e2185-e94e-4a90-907e-15dad519fd59] Started GET "/" for 188.83.235.112 at 2017-02-24 21:30:27 +0000
2017-02-24T21:30:27.867090+00:00 app[web.1]: I, [2017-02-24T21:30:27.867030 #4]  INFO -- : [ef1e2185-e94e-4a90-907e-15dad519fd59] Processing by PagesController#home as HTML
2017-02-24T21:30:27.868034+00:00 app[web.1]: I, [2017-02-24T21:30:27.867962 #4]  INFO -- : [ef1e2185-e94e-4a90-907e-15dad519fd59]   Rendering pages/home.html.erb within layouts/application
2017-02-24T21:30:27.868172+00:00 app[web.1]: I, [2017-02-24T21:30:27.868117 #4]  INFO -- : [ef1e2185-e94e-4a90-907e-15dad519fd59]   Rendered pages/home.html.erb within layouts/application (0.0ms)
2017-02-24T21:30:27.869109+00:00 app[web.1]: I, [2017-02-24T21:30:27.869058 #4]  INFO -- : [ef1e2185-e94e-4a90-907e-15dad519fd59] Completed 200 OK in 2ms (Views: 1.3ms | ActiveRecord: 0.0ms)
2017-02-24T21:30:28.039850+00:00 heroku[router]: at=info method=GET path="/assets/application-5ed627eba0abe94ba4e2c255c2298f55d9bca9b4ea45ded59ba1705edc5385d0.css" host=infinite-forest-28304.herokuapp.com request_id=f9b48384-ae99-4f9e-b035-6624ef9d2ce6 fwd="188.83.235.112" dyno=web.1 connect=0ms service=1ms status=304 bytes=48
2017-02-24T21:30:28.051038+00:00 heroku[router]: at=info method=GET path="/assets/application-95163fa38446d1bb6139f870d5fb932af7fa47b347b8951923c32a4565386aa6.js" host=infinite-forest-28304.herokuapp.com request_id=7b1f62bf-5aca-4ac1-b926-5c3219b3ccac fwd="188.83.235.112" dyno=web.1 connect=1ms service=2ms status=304 bytes=48
2017-02-24T21:30:28.279062+00:00 heroku[router]: at=info method=GET path="/assets/font-awesome/fontawesome-webfont-2932abf996373e87fbf2e950876b1962f1b57db954a1643ea68831d9fbb74da4.woff2?v=4.6.2" host=infinite-forest-28304.herokuapp.com request_id=d1522ce1-c16b-4525-aa55-08c6f45713c8 fwd="188.83.235.112" dyno=web.1 connect=0ms service=1ms status=304 bytes=48
2017-02-24T21:30:29.186402+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=infinite-forest-28304.herokuapp.com request_id=1cec8754-06b9-4b20-ad32-77976a359e33 fwd="188.83.235.112" dyno=web.1 connect=0ms service=1ms status=304 bytes=48

【问题讨论】:

请通过在命令外壳的应用目录中运行 heroku 日志来发布日志 如果您的配置有问题请检查,如果您的 Rails 代码有问题,请同时发布该代码 @KcUS_unico 你好,当我做“heroku 日志”时,我收到了很多东西……我什至不知道从什么地方开始复制。我将在收到错误后从日志中复制一份,同时,您希望查看代码中的哪一部分。任何特定的控制器、邮件程序或其他任何东西? 请张贴整个heroku日志.. heroku 日志发布 【参考方案1】:

阅读错误信息:

Net::SMTPFatalError (554 Please activate your Mailgun account. Check your inbox or log in to your control panel to resend the activation email.

只需激活您的帐户。

【讨论】:

该帐户从一开始就已激活,因为它显示“看起来此帐户已被激活”。但是,它仍然不起作用。当我要求重新发送激活时,我从 MailGun 收到“服务器错误/发生内部服务器错误”。无论如何感谢您的帮助。 抱歉没用。不幸的是,这些日志只说该帐户未激活。 Sendgrid 是另一个邮件提供商,它也提供免费计划,并且与 heroku 配合得很好。【参考方案2】:

好的。正如日志所说,正如@GrahamSlick 已经回答的那样,您的mailgun 帐户未经过验证。如果您声称该帐户已通过验证,请确保您使用的凭据 您的 config/environment.rb 是属于已验证帐户的正确帐户,并确保 heroku 使用正确的凭据。日志显示您的帐户未经过验证。可能您想再次使用 mailgun 检查您的设置,看看它们是否告诉您有关拥有非活动帐户的信息。祝你好运。

【讨论】:

该帐户从一开始就已激活,因为它显示“看起来此帐户已被激活”。但是,它仍然不起作用。当我要求重新发送激活时,我从 MailGun 收到“服务器错误/发生内部服务器错误”。无论如何感谢您的帮助。【参考方案3】:

您必须添加一个域,验证它,然后您才能从 mailgun 发送邮件。

【讨论】:

如果您已经添加了域但仍然无法使用,那么您可以在 mailgun 支持上添加票证以进行验证。【参考方案4】:

我遇到了完全相同的问题。我什至尝试只使用 CURL 以确保它与 rails 或 heroku 无关。我仔细检查了我的域是否经过验证。

我最终打开了一张支持票。他们在几个小时内回复了我并说“现在可以开始了”,果然成功了。

因此,要么是他们的错误,要么是他们故意要求对某些帐户进行人工监督。第一印象不是很好,但很高兴看到他们的支持迅速得到响应。

【讨论】:

以上是关于Heroku 环境中的 Ruby on Rails 应用程序:“使用 Mailgun 发送电子邮件”错误的主要内容,如果未能解决你的问题,请参考以下文章

Ruby on Rails 中的 Sendgrid / 电子邮件发送问题(托管在 Heroku 上)

Django 有没有像 Ruby on Rails 有 Heroku 这样的东西

推送到Heroku时Ruby on Rails错误

heroku 部署错误 ruby​​ on rails

ruby on rails Heroku 迁移错误

在 Ruby on Rails 中使用 Heroku