【发布时间】:2013-12-09 09:24:42
【问题描述】:
我正在尝试为我在 Heroku 上的网站的新用户设置电子邮件确认。 它在开发中工作正常(它是从正确的电子邮件发送的,即使我从未在 development.rb 中指定它)
这是 development.rb 中的代码:(我使用的是 MailCatcher)
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { :host => 'localhost:3000'}
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {:address => "localhost", :port => 1025}
这是production.rb中的代码:
config.action_mailer.default_url_options = {:host => 'myapp.herokuapp.com'}
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => 'myapp.herokuapp.com', #I've also tried changing this to 'gmail.com'
:authentication => :plain, # I've also tried changing this to :login
:enable_starttls_auto => true,
:user_name => 'mygmailaccount@gmail.com',
:password => 'mypassword'
}
当我在命令提示符下键入“heroku 日志”时,这里是最后几个(很长的)Heroku 日志:
2013-11-24T18:51:01.069086+00:00 app[web.1]: Rendered layouts/_header.html.erb
(1.4ms)
2013-11-24T18:50:57.403500+00:00 heroku[router]: at=info method=GET path=/users/
confirmation/new host=myapp.herokuapp.com fwd="118.22.125.86" dyno=we
b.1 connect=30ms service=18ms status=304 bytes=0
2013-11-24T18:50:32.655624+00:00 heroku[router]: at=info method=GET path=/users/
sign_up host=myapp.herokuapp.com fwd="118.22.125.86" dyno=web.1 conne
ct=25ms service=78ms status=304 bytes=0
Heroku 上的生产网站只是说“我们很抱歉,但出了点问题。”电子邮件永远不会被发送。具有指定电子邮件的帐户永远不会登录到数据库。
编辑:这是我添加 config.log_level = :debug 后的日志文件
2013-11-24T20:35:31.602702+00:00 heroku[router]: at=info method=GET path=/favico
n.ico host=myapp.herokuapp.com fwd="118.22.125.86" dyno=web.1 connect
=2ms service=9ms status=304 bytes=0
2013-11-24T20:35:13.963743+00:00 heroku[router]: at=info method=GET path=/favico
n.ico host=myapp.herokuapp.com fwd="118.22.125.86" dyno=web.1 connect
=1ms service=447ms status=200 bytes=0
还有一个:
2013-11-24T20:38:32.693982+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rac
k-1.4.5/lib/rack/handler/webrick.rb:59:in `service'
2013-11-24T20:38:32.694321+00:00 app[web.1]: vendor/ruby-2.0.0/lib/ruby/2.0.0/
webrick/server.rb:295:in `block in start_thread'
2013-11-24T20:38:32.693982+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rac
k-cache-1.2/lib/rack/cache/context.rb:51:in `call'
2013-11-24T20:38:32.693982+00:00 app[web.1]: vendor/ruby-2.0.0/lib/ruby/2.0.0/
webrick/httpserver.rb:94:in `run'
2013-11-24T20:38:32.693982+00:00 app[web.1]: vendor/ruby-2.0.0/lib/ruby/2.0.0/
webrick/httpserver.rb:138:in `service'
这些只是最后几个日志。整个日志太长,无法在此处复制。我不确定要寻找什么。
【问题讨论】:
-
我什至尝试将文件名 development.rb 更改为 production.rb ,反之亦然,以尝试查看发生了什么。在这种情况下,它仍然可以在开发中使用,但不能用于生产。
标签: ruby-on-rails heroku devise production confirmation