2

我的 rails 应用程序具有一个使用 smtp 的邮件系统。

我的应用程序在 localhost 和我的办公室和家里的生产环境中完美运行。但是在有防火墙的公司办公室,我通过以太网连接,邮件系统出现故障并且出现了问题。当时我不确定该错误,因为它正在生产中,并且我看不到错误消息。我没有时间在 localhost 上进行测试。

在另一个公司大楼,使用他们的访客 wifi,我试图在本地主机上向用户发送邮件,我收到超时错误,但它在生产网站上运行良好。这是我得到的错误:

Net::OpenTimeout: execution expired
from ~/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/smtp.rb:540:in `initialize'
from ~/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/smtp.rb:540:in `open'
from ~/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/smtp.rb:540:in `tcp_socket'
from ~/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/smtp.rb:550:in `block in do_start'
from ~/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/smtp.rb:549:in `do_start'
from ~/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/smtp.rb:519:in `start'
from ~/.rvm/gems/ruby-2.0.0-p0/gems/mail-2.5.3/lib/mail/network/delivery_methods/smtp.rb:136:in `deliver!'
from ~/.rvm/gems/ruby-2.0.0-p0/gems/mail-2.5.3/lib/mail/message.rb:2033:in `do_delivery'
from ~/.rvm/gems/ruby-2.0.0-p0/gems/mail-2.5.3/lib/mail/message.rb:229:in `block in deliver'
from ~/.rvm/gems/ruby-2.0.0-p0/gems/actionmailer-3.2.13/lib/action_mailer/base.rb:415:in `block in deliver_mail'
from ~/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/notifications.rb:123:in `block in instrument'
from ~/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
from ~/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.13/lib/active_support/notifications.rb:123:in `instrument'
from ~/.rvm/gems/ruby-2.0.0-p0/gems/actionmailer-3.2.13/lib/action_mailer/base.rb:413:in `deliver_mail'
from ~/.rvm/gems/ruby-2.0.0-p0/gems/mail-2.5.3/lib/mail/message.rb:229:in `deliver'
from (irb):6
from ~/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start'
from ~/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start'
from ~/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in 

这是 setup_mail.rb 文件:

ActionMailer::Base.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => 587,
  :domain               => "domain",
  :user_name            => "user@gmail.com",
  :password             => "password",
  :authentication       => "plain",
  :enable_starttls_auto => true
}

是端口的问题吗?如果是这样,我应该使用哪个端口,为什么?

如何解决此超时错误?我怎样才能绕过防火墙?非常感谢任何帮助和建议。谢谢!

4

0 回答 0