【问题标题】:Rails 2.3.9 and SendGrid, Connection refused - connect(2) on localhostRails 2.3.9 和 SendGrid,连接被拒绝 - 本地主机上的连接(2)
【发布时间】:2011-07-10 13:54:44
【问题描述】:

我查看了 Google 和 StackOverflow,但无法弄清楚。

我有一个使用 Ruby 1.8.7 的 Rails 2.3.9 应用程序,尝试通过 SMTP 发送电子邮件,如下所示:

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

我的应用回溯如下所示:

/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.rb: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'

【问题讨论】:

  • 你能telnet smtp.sendgrid.net 25吗?您是否正在运行诸如 Little Snitch 之类的网络过滤器并阻止传出连接?一些 ISP 还阻止传出端口 25,要求您连接到他们的 SMTP 服务器(表面上是为了让他们的用户更难发送垃圾邮件)。
  • 不,我不能。这验证了我在下面提出的解决方案。

标签: ruby-on-rails ruby actionmailer sendgrid


【解决方案1】:

我想通了。我的 ISP 阻塞了 25 端口,所以我不得不更改我的配置:

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

【讨论】:

    猜你喜欢
    • 2020-03-14
    • 2015-07-30
    • 2014-05-31
    • 2016-01-27
    • 2015-12-12
    • 2015-09-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多