我使用Ruby 2.0.0 MRI和Ubuntu的12.04 TLS VPS的Rails 3.2.12,并试图设置电子邮件通知我的应用程序。 这是工作的罚款前几天,但现在不是了。 我的虚拟主机是OVH。
我的SMTP设置:
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:user_name => 'sender@gmail.com',
:password => 'secret',
:authentication => 'plain',
:enable_starttls_auto => true
}
使用RAILS_ENV=production rails console
:
class MyMailer < ActionMailer::Base
def test_email
sender = "sender@gmail.com"
receiver = "receiver@example.com"
mail from: sender, to: receiver, subject: "Hello!", body: "World!!"
end
end
=> nil
MyMailer.test_email.deliver
输出:
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@mygemset/gems/mail-2.4.4/lib/mail/network/delivery_methods/smtp.rb:144:in `deliver!'
from ~/.rvm/gems/ruby-2.0.0-p0@mygemset/gems/mail-2.4.4/lib/mail/message.rb:2034:in `do_delivery'
from ~/.rvm/gems/ruby-2.0.0-p0@mygemset/gems/mail-2.4.4/lib/mail/message.rb:229:in `block in deliver'
from ~/.rvm/gems/ruby-2.0.0-p0@mygemset/gems/actionmailer-3.2.12/lib/action_mailer/base.rb:415:in `block in deliver_mail'
from ~/.rvm/gems/ruby-2.0.0-p0@mygemset/gems/activesupport-3.2.12/lib/active_support/notifications.rb:123:in `block in instrument'
from ~/.rvm/gems/ruby-2.0.0-p0@mygemset/gems/activesupport-3.2.12/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
from ~/.rvm/gems/ruby-2.0.0-p0@mygemset/gems/activesupport-3.2.12/lib/active_support/notifications.rb:123:in `instrument'
from ~/.rvm/gems/ruby-2.0.0-p0@mygemset/gems/actionmailer-3.2.12/lib/action_mailer/base.rb:413:in `deliver_mail'
from ~/.rvm/gems/ruby-2.0.0-p0@mygemset/gems/mail-2.4.4/lib/mail/message.rb:229:in `deliver'
from (irb):28
from ~/.rvm/gems/ruby-2.0.0-p0@mygemset/gems/railties-3.2.12/lib/rails/commands/console.rb:47:in `start'
from ~/.rvm/gems/ruby-2.0.0-p0@mygemset/gems/railties-3.2.12/lib/rails/commands/console.rb:8:in `start'
from ~/.rvm/gems/ruby-2.0.0-p0@mygemset/gems/railties-3.2.12/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'2.0.0p0 :029 >
我试过如下:
- 该
exception_notification
宝石加入到设置在几天前。 我试图评论它的线Gemfile
以及与其相配套的配置,并运行bundle install
。 重新启动服务器后,问题仍然存在,即使我删除并重新创建宝石。 - 测试它在虚拟机上(完全相同的设置作为VPS包括iptables规则): 作品
- 禁用iptables规则: 不工作
- 使用OpenSSL的从VPS手动连接到Gmail: 作品 (所以这不是一个防火墙的问题-在这里看到: 通过命令行连接到smtp.gmail.com );
- 启用Gmail帐户的选项IMAP(它被禁用): 不工作
- 使用不同的Gmail帐户: 不工作
- 由红宝石1.9.3更换红宝石2.0.0
- 升级到Rails 3.2.13
是否有人有一个可能的线索,如何解决这个问题?
谢谢!