highBandWidth
highBandWidth

Reputation: 17321

Sendgrid connection refused

I am developing a Ruby on Rails 3.2 application on Heroku. I added the sendgrid addon with

heroku addons:add sendgrid:starter

and then restarted with

heroku restart

However, if I try to send a password email in my application (I am using the devise login gem), I get this in the logs

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"=>"[email protected]"}, "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 [email protected] (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'

Upvotes: 1

Views: 2130

Answers (1)

eugen
eugen

Reputation: 9226

You need to configure ActiveMailer with something like

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']
}

and make sure your application has the SENGRID configuration variables in the environment - you can check with heroku config.

Upvotes: 3

Related Questions