Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 3 拒绝电网连接_Ruby On Rails 3_Heroku_Smtp_Sendgrid - Fatal编程技术网

Ruby on rails 3 拒绝电网连接

Ruby on rails 3 拒绝电网连接,ruby-on-rails-3,heroku,smtp,sendgrid,Ruby On Rails 3,Heroku,Smtp,Sendgrid,我正在Heroku上开发RubyonRails3.2应用程序。我添加了sendgrid插件 heroku addons:add sendgrid:starter 然后用 heroku restart 但是,如果我尝试在我的应用程序中发送一封密码电子邮件(我使用的是Desive登录gem),我会在日志中得到它 2013-01-24T17:35:37+00:00 app[web.1]: Started POST "/users/password" for xxx.xxx.xxx.xx at 20

我正在Heroku上开发RubyonRails3.2应用程序。我添加了sendgrid插件

heroku addons:add sendgrid:starter
然后用

heroku restart
但是,如果我尝试在我的应用程序中发送一封密码电子邮件(我使用的是Desive登录gem),我会在日志中得到它

2013-01-24T17:35:37+00:00 app[web.1]: Started POST "/users/password" for xxx.xxx.xxx.xx at 2013-01-24 17:35:37 +0000
2013-01-24T17:35:37+00:00 app[web.1]: Processing by Devise::PasswordsController#create as HTML
2013-01-24T17:35:37+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "authenticity_token"=>"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=", "user"=>{"email"=>"xxxxxxxx.xxxxxx@gmail.com"}, "commit"=>"Send me reset password instructions"}
2013-01-24T17:35:38+00:00 app[web.1]:   Rendered vendor/bundle/ruby/1.9.1/gems/devise-2.2.2/app/views/devise/mailer/reset_password_instructions.html.erb (1.0ms)
2013-01-24T17:35:41+00:00 app[web.1]: 
2013-01-24T17:35:41+00:00 app[web.1]: Sent mail to xxx.xxxxx@gmail.com (3080ms)
2013-01-24T17:35:41+00:00 app[web.1]: Completed 500 Internal Server Error in 3311ms
2013-01-24T17:35:41+00:00 app[web.1]: 
2013-01-24T17:35:41+00:00 app[web.1]: Errno::ECONNREFUSED (Connection refused - connect(2)):
2013-01-24T17:35:41+00:00 app[web.1]:   /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `initialize'
2013-01-24T17:35:41+00:00 app[web.1]:   /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `open'
2013-01-24T17:35:41+00:00 app[web.1]:   /usr/local/lib/ruby/1.9.1/net/smtp.rb:546:in `tcp_socket'
2013-01-24T17:35:41+00:00 app[web.1]:   /usr/local/lib/ruby/1.9.1/net/smtp.rb:555:in `block in do_start'
2013-01-24T17:35:41+00:00 app[web.1]:   /usr/local/lib/ruby/1.9.1/timeout.rb:58:in `timeout'
2013-01-24T17:35:41+00:00 app[web.1]:   /usr/local/lib/ruby/1.9.1/timeout.rb:89:in `timeout'
2013-01-24T17:35:41+00:00 app[web.1]:   /usr/local/lib/ruby/1.9.1/net/smtp.rb:555:in `do_start'
2013-01-24T17:35:41+00:00 app[web.1]:   /usr/local/lib/ruby/1.9.1/net/smtp.rb:525:in `start'
2013-01-24T17:35:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/network/delivery_methods/smtp.rb:144:in `deliver!'
2013-01-24T17:35:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/message.rb:2034:in `do_delivery'

您需要使用以下内容配置
ActiveMailer

ActionMailer::Base.smtp_settings = {
  :address        => "smtp.sendgrid.net",
  :port           => "25",
  :authentication => :plain,
  :user_name      => ENV['SENDGRID_USERNAME'],
  :password       => ENV['SENDGRID_PASSWORD'],
  :domain         => ENV['SENDGRID_DOMAIN']
}
并确保您的应用程序在环境中具有SENGRID配置变量-您可以使用
heroku config
进行检查