开发者

Rails 2.3.9 and SendGrid, Connection refused - connect(2) on localhost

I've looked through Google and StackOverflow and can't figure this out.

I've got a Rails 2.3.9 app using Ruby 1.8.7, trying to send email through SMTP like so:

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
  :address => "smtp.sendgrid.net",
  :port => '25',
  :domain => "************.com",
  :authentication => :plain,
  :user_name => "***********",
  :password => "**********"
}

My app backtrace looks like this:

/Users/jared/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/net/smtp.rb:551:in `initialize'
/Users/jared/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/net/smtp.rb:551:in `open'
/Users/jared/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/net/smtp.rb:551:in `do_start'
/Users/jared/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/timeout.rb:67:in `timeout'
/Users/jared/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/timeout.rb:101:in `timeout'
/Users/jared/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/net/smtp.rb:551:in `do_start'
/Users/jared/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/net/smtp.rb:525:in `start'
/Users/jared/.rvm/gems/ruby-1.8.7-p334/gems/actionmailer-2.3.9/lib/action_mailer/base.rb:682:in `perform_delivery_smtp'
/Users/jared/.rvm/gems/ruby-1.8.7-p334/gems/actionmailer-2.3.9/lib/action_mailer/base.r开发者_C百科b:523:in `__send__'
/Users/jared/.rvm/gems/ruby-1.8.7-p334/gems/actionmailer-2.3.9/lib/action_mailer/base.rb:523:in `deliver!'
/Users/jared/.rvm/gems/ruby-1.8.7-p334/gems/actionmailer-2.3.9/lib/action_mailer/base.rb:429:in `deliver'
/Users/jared/rails/********/app/models/user.rb:160:in `send_welcome_email'
/Users/jared/rails/*********/app/controllers/users_controller.rb:35:in `create'


I figured it out. My ISP was blocking port 25, so I had to change my configuration:

ActionMailer::Base.smtp_settings = {
  :address => "smtp.sendgrid.net",
  :port => '587',
  :domain => "**********.com",
  :authentication => :plain,
  :user_name => "************",
  :password => "*********",
  :enable_starttls_auto => true
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜