使用 imap.rb 连接到 imap.google.com 时连接被拒绝

Connection refused when using imap.rb to connect to imap.google.com

我正在尝试连接到 Gmail 帐户(通过 OAuth 2.0 ruby-gmail gem, gmail gem, gmail_xoauth gem,但每种方法都使用 imap.rb)并获得:

C:/Ruby21-x64/lib/ruby/2.1.0/net/imap.rb:1045:in `initialize': No connection could be made because the target machine actively refused it. - connect(2) for "imap.gmail.com" port 993 (Errno::ECONNREFUSED)

我的 Gmail 帐户:

  1. 确保可以通过网页登录访问
  2. 确保已激活
  3. 已启用 IMAP
  4. 允许不安全的应用访问

在我的连接中:

  1. 确保它是通过 SSL 创建的
  2. 确保在适用的情况下使用正确的登录详细信息和令牌
  3. 已尝试端口 993 和 465

我还能尝试什么?我如何在无法控制的情况下排除防火墙的问题?

.. (Errno::ECONNREFUSED)

... How could I rule out the firewall being the issue, without having control over it?

可能是防火墙。错误消息表明与服务的连接被主动拒绝。由于它对我有用,我怀疑是 google 本身拒绝了该服务,因此它必须是介于两者之间的防火墙。