邮件未在 rails 上使用 devise、heroku 和邮戳发送
Posted
技术标签:
【中文标题】邮件未在 rails 上使用 devise、heroku 和邮戳发送【英文标题】:mail not sending using devise, heroku, and postmark on rails 【发布时间】:2013-10-10 22:23:00 【问题描述】:我的应用程序发送忘记密码的电子邮件时遇到问题 - 请在下面查看我的 heroku 日志...任何帮助都会非常感谢您,因为我是邮件集成的新手,似乎无法破译这些日志.. ...
C:\sites\code\OM Rails\omrails>heroku logs
2013-10-03T23:05:47.311429+00:00 app[web.1]: [2013-10-03 23:05:47] INFO WEBrick
1.3.1
2013-10-03T23:05:47.830949+00:00 heroku[web.1]: State changed from starting to u
p
2013-10-03T23:05:50.698906+00:00 app[web.1]: Processing by PinsController#index
as html
2013-10-03T23:05:50.698906+00:00 app[web.1]: Rendered pages/_home.html.erb (1.
0ms)
2013-10-03T23:05:50.698906+00:00 app[web.1]: Rendered pins/_pin.html.erb (1515
.1ms)
2013-10-03T23:05:50.698906+00:00 app[web.1]: Rendered pins/index.html.erb with
in layouts/application (1828.3ms)
2013-10-03T23:05:50.698906+00:00 app[web.1]: Rendered layouts/_header.html.erb
(1.7ms)
2013-10-03T23:05:50.698906+00:00 app[web.1]: Rendered layouts/_footer.html.erb
(2.6ms)
2013-10-03T23:05:50.698906+00:00 app[web.1]: Completed 200 OK in 1866ms (Views:
1308.1ms | ActiveRecord: 556.1ms)
2013-10-03T23:05:50.703726+00:00 heroku[router]: at=info method=GET path=/ host=
www.barnpix.com fwd="67.165.53.20" dyno=web.1 connect=7ms service=2005ms status=
304 bytes=0
2013-10-03T23:05:48.712294+00:00 app[web.1]: => Booting WEBrick
2013-10-03T23:05:48.712294+00:00 app[web.1]: => Call with -d to detach
2013-10-03T23:05:48.712294+00:00 app[web.1]: => Rails 3.2.13 application startin
g in production on http://0.0.0.0:55376
2013-10-03T23:05:48.712294+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-10-03T23:05:48.712294+00:00 app[web.1]: Started GET "/" for 67.165.53.20 at
2013-10-03 23:05:48 +0000
2013-10-03T23:05:52.369609+00:00 app[web.1]: Started GET "/users/sign_in" for 67
.165.53.20 at 2013-10-03 23:05:52 +0000
2013-10-03T23:05:52.563215+00:00 heroku[router]: at=info method=GET path=/users/
sign_in host=www.barnpix.com fwd="67.165.53.20" dyno=web.1 connect=2ms service=2
12ms status=200 bytes=4806
2013-10-03T23:05:52.559347+00:00 app[web.1]: Completed 200 OK in 178ms (Views: 1
75.3ms | ActiveRecord: 0.0ms)
2013-10-03T23:05:52.559347+00:00 app[web.1]: Processing by Devise::SessionsContr
oller#new as HTML
2013-10-03T23:05:52.559347+00:00 app[web.1]: Rendered devise/shared/_links.erb
(3.0ms)
2013-10-03T23:05:52.559347+00:00 app[web.1]: Rendered devise/sessions/new.html
.erb within layouts/application (166.7ms)
2013-10-03T23:05:52.559347+00:00 app[web.1]: Rendered layouts/_header.html.erb
(3.2ms)
2013-10-03T23:05:52.559347+00:00 app[web.1]: Rendered layouts/_footer.html.erb
(0.0ms)
2013-10-03T23:05:53.985381+00:00 app[web.1]: Started GET "/users/password/new" f
or 67.165.53.20 at 2013-10-03 23:05:53 +0000
2013-10-03T23:05:54.009692+00:00 heroku[router]: at=info method=GET path=/users/
password/new host=www.barnpix.com fwd="67.165.53.20" dyno=web.1 connect=2ms serv
ice=34ms status=200 bytes=3961
2013-10-03T23:05:54.006814+00:00 app[web.1]: Processing by Devise::PasswordsCont
roller#new as HTML
2013-10-03T23:05:54.006814+00:00 app[web.1]: Rendered devise/shared/_links.erb
(0.5ms)
2013-10-03T23:05:54.006814+00:00 app[web.1]: Rendered devise/passwords/new.htm
l.erb within layouts/application (9.1ms)
2013-10-03T23:05:54.006814+00:00 app[web.1]: Completed 200 OK in 16ms (Views: 14
.1ms | ActiveRecord: 0.0ms)
2013-10-03T23:05:54.006814+00:00 app[web.1]: Rendered layouts/_footer.html.erb
(0.0ms)
2013-10-03T23:05:54.006814+00:00 app[web.1]: Rendered layouts/_header.html.erb
(1.5ms)
2013-10-03T23:05:56.614509+00:00 app[web.1]: Started POST "/users/password" for
67.165.53.20 at 2013-10-03 23:05:56 +0000
2013-10-03T23:05:57.468781+00:00 heroku[router]: at=info method=POST path=/users
/password host=www.barnpix.com fwd="67.165.53.20" dyno=web.1 connect=3ms service
=864ms status=500 bytes=643
2013-10-03T23:05:57.463544+00:00 app[web.1]:
2013-10-03T23:05:57.463544+00:00 app[web.1]: ActionView::Template::Error (Missin
g host to link to! Please provide the :host parameter, set default_url_options[:
host], or set :only_path to true):
2013-10-03T23:05:57.463544+00:00 app[web.1]: 2:
2013-10-03T23:05:57.463544+00:00 app[web.1]: 1: <p>Someone has requested a l
ink to change your password. You can do this through the link below.</p>
2013-10-03T23:05:57.463544+00:00 app[web.1]: 4:
2013-10-03T23:05:57.463730+00:00 app[web.1]:
2013-10-03T23:05:57.463544+00:00 app[web.1]: app/mailers/user_mailer.rb:8:in `
reset_password_instructions'
2013-10-03T23:05:57.463544+00:00 app[web.1]: 6: <p>Your password won't chan
ge until you access the link above and create a new one.</p>
2013-10-03T23:05:57.463730+00:00 app[web.1]:
2013-10-03T23:05:57.463544+00:00 app[web.1]: 5: <p>If you didn't request thi
s, please ignore this email.</p>
2013-10-03T23:05:57.463919+00:00 app[web.1]: Completed 500 Internal Server Error
in 841ms
2013-10-03T23:05:57.463919+00:00 app[web.1]: Parameters: "utf8"=>"???", "auth
enticity_token"=>"qxyBKeQgmrZw2y9ZBQXzHDKoou9gUExjZbu56qFpbhc=", "user"=>"email
"=>"westc@duq.edu", "commit"=>"Send me reset password instructions"
2013-10-03T23:05:57.463919+00:00 app[web.1]: Rendered user_mailer/reset_passwo
rd_instructions.html.erb (3.0ms)
2013-10-03T23:05:57.463919+00:00 app[web.1]: Processing by Devise::PasswordsCont
roller#create as HTML
2013-10-03T23:05:57.463544+00:00 app[web.1]: 3: <p><%= link_to 'Change my pa
ssword', edit_password_url(@resource, :reset_password_token => @token) %></p>
2013-10-03T23:05:57.463544+00:00 app[web.1]: app/views/user_mailer/reset_passw
ord_instructions.html.erb:3:in `_app_views_user_mailer_reset_password_instructio
ns_html_erb___776492356719999189_70021683802400'
2013-10-03T23:06:46.271473+00:00 app[web.1]: 3: <p><%= link_to 'Change my pa
ssword', edit_password_url(@resource, :reset_password_token => @token) %></p>
2013-10-03T23:06:46.271473+00:00 app[web.1]: 4:
2013-10-03T23:06:46.271473+00:00 app[web.1]: 5: <p>If you didn't request thi
s, please ignore this email.</p>
2013-10-03T23:06:46.271473+00:00 app[web.1]: 6: <p>Your password won't chan
ge until you access the link above and create a new one.</p>
2013-10-03T23:06:46.271473+00:00 app[web.1]: app/views/user_
mailer/reset_password_instructions.html.erb:3:in `_app_views_user_mailer_reset_p
assword_instructions_html_erb___776492356719999189_70021683802400'
2013-10-03T23:06:46.271473+00:00 app[web.1]: app/mailers/user_mailer.rb:8:in `
reset_password_instructions'
2013-10-03T23:06:46.271691+00:00 app[web.1]:
2013-10-03T23:06:46.271691+00:00 app[web.1]:
2013-10-03T23:06:46.271954+00:00 app[web.1]: Processing by Devise::PasswordsCont
roller#create as HTML
2013-10-03T23:06:46.271954+00:00 app[web.1]: Completed 500 Internal Server Error
in 37ms
2013-10-03T23:06:46.271473+00:00 app[web.1]: 2:
2013-10-03T23:06:46.271473+00:00 app[web.1]: 1: <p>Someone has requested a l
ink to change your password. You can do this through the link below.</p>
2013-10-03T23:06:46.271473+00:00 app[web.1]:
2013-10-03T23:06:46.271954+00:00 app[web.1]: Rendered user_mailer/reset_passwo
rd_instructions.html.erb (1.1ms)
2013-10-03T23:06:46.271954+00:00 app[web.1]: Parameters: "utf8"=>"???", "auth
enticity_token"=>"qxyBKeQgmrZw2y9ZBQXzHDKoou9gUExjZbu56qFpbhc=", "user"=>"email
"=>"westc@duq.edu", "commit"=>"Send me reset password instructions"
2013-10-03T23:06:46.225237+00:00 app[web.1]: Started POST "/users/password" for
67.165.53.20 at 2013-10-03 23:06:46 +0000
2013-10-03T23:06:46.271473+00:00 app[web.1]: ActionView::Template::Error (Missin
g host to link to! Please provide the :host parameter, set default_url_options[:
host], or set :only_path to true):
2013-10-03T23:06:46.278030+00:00 heroku[router]: at=info method=POST path=/users
/password host=www.barnpix.com fwd="67.165.53.20" dyno=web.1 connect=4ms service
=66ms status=500 bytes=643
2013-10-03T23:08:56.448922+00:00 heroku[router]: at=info method=GET path=/tags/t
rail%20ride host=www.barnpix.com fwd="5.10.83.33" dyno=web.1 connect=1ms service
=81ms status=200 bytes=5205
2013-10-03T23:08:56.439603+00:00 app[web.1]: Rendered layouts/_header.html.erb
(0.7ms)
2013-10-03T23:08:56.439603+00:00 app[web.1]: Rendered pins/index.html.erb with
in layouts/application (27.4ms)
2013-10-03T23:08:56.439603+00:00 app[web.1]: Completed 200 OK in 51ms (Views: 15
.1ms | ActiveRecord: 30.9ms)
2013-10-03T23:08:56.439603+00:00 app[web.1]: Processing by PinsController#index
as */*
2013-10-03T23:08:56.377015+00:00 app[web.1]: Started GET "/tags/trail%20ride" fo
r 5.10.83.33 at 2013-10-03 23:08:56 +0000
2013-10-03T23:08:56.439603+00:00 app[web.1]: Rendered pins/_pin.html.erb (14.9
ms)
2013-10-03T23:08:56.439603+00:00 app[web.1]: Parameters: "tag"=>"trail ride"
2013-10-03T23:08:56.439603+00:00 app[web.1]: Rendered pages/_home.html.erb (0.
4ms)
2013-10-03T23:08:56.439603+00:00 app[web.1]: Rendered layouts/_footer.html.erb
(0.0ms)
2013-10-03T23:10:28.304809+00:00 app[web.1]: Started GET "/tags/draft%20cross" f
or 5.10.83.88 at 2013-10-03 23:10:28 +0000
2013-10-03T23:10:28.347181+00:00 heroku[router]: at=info method=GET path=/tags/d
raft%20cross host=www.barnpix.com fwd="5.10.83.88" dyno=web.1 connect=2ms servic
e=162ms status=200 bytes=5313
2013-10-03T23:10:28.349215+00:00 app[web.1]: Processing by PinsController#index
as */*
2013-10-03T23:10:28.349215+00:00 app[web.1]: Parameters: "tag"=>"draft cross"
2013-10-03T23:10:28.349215+00:00 app[web.1]: Rendered pages/_home.html.erb (0.
4ms)
2013-10-03T23:10:28.349215+00:00 app[web.1]: Rendered pins/_pin.html.erb (13.8
ms)
2013-10-03T23:10:28.349215+00:00 app[web.1]: Rendered pins/index.html.erb with
in layouts/application (20.1ms)
2013-10-03T23:10:28.349215+00:00 app[web.1]: Rendered layouts/_header.html.erb
(0.7ms)
2013-10-03T23:10:28.349215+00:00 app[web.1]: Rendered layouts/_footer.html.erb
(0.0ms)
2013-10-03T23:10:28.349215+00:00 app[web.1]: Completed 200 OK in 34ms (Views: 11
.1ms | ActiveRecord: 20.3ms)
2013-10-03T23:11:25.716716+00:00 app[web.1]: Started GET "/pins/281" for 5.10.83
.102 at 2013-10-03 23:11:25 +0000
2013-10-03T23:11:25.727357+00:00 app[web.1]: Processing by PinsController#show a
s */*
2013-10-03T23:11:25.732894+00:00 heroku[router]: at=info method=GET path=/pins/2
81 host=www.barnpix.com fwd="5.10.83.102" dyno=web.1 connect=0ms service=28ms st
atus=302 bytes=102
2013-10-03T23:11:25.727357+00:00 app[web.1]: Completed 401 Unauthorized in 1ms
2013-10-03T23:11:25.727357+00:00 app[web.1]: Parameters: "id"=>"281"
2013-10-03T23:11:31.449774+00:00 app[web.1]: Started GET "/" for 5.10.83.33 at 2
013-10-03 23:11:31 +0000
2013-10-03T23:11:32.961670+00:00 heroku[router]: at=info method=GET path=/ host=
www.barnpix.com fwd="5.10.83.33" dyno=web.1 connect=0ms service=1526ms status=20
0 bytes=47546
2013-10-03T23:11:32.962074+00:00 app[web.1]: Processing by PinsController#index
as */*
2013-10-03T23:11:32.962074+00:00 app[web.1]: Rendered pages/_home.html.erb (0.
4ms)
2013-10-03T23:11:32.962074+00:00 app[web.1]: Rendered pins/_pin.html.erb (1469
.5ms)
2013-10-03T23:11:32.962074+00:00 app[web.1]: Rendered pins/index.html.erb with
in layouts/application (1492.5ms)
2013-10-03T23:11:32.962074+00:00 app[web.1]: Rendered layouts/_header.html.erb
(0.7ms)
2013-10-03T23:11:32.962074+00:00 app[web.1]: Rendered layouts/_footer.html.erb
(0.0ms)
2013-10-03T23:11:32.962074+00:00 app[web.1]: Completed 200 OK in 1501ms (Views:
1019.4ms | ActiveRecord: 480.0ms
【问题讨论】:
【参考方案1】:在您的config/environments/development.rb
中添加以下行
config.action_mailer.default_url_options = :host => 'localhost:3000'
在 production.rb 中,添加您网站的正确 URL
【讨论】:
以上是关于邮件未在 rails 上使用 devise、heroku 和邮戳发送的主要内容,如果未能解决你的问题,请参考以下文章
Rails 4、Devise 和 Mandrill 电子邮件
Ruby/Rails:您如何自定义 Devise 的邮件模板?
Ruby/Rails:您如何自定义 Devise 的邮件模板?