相关疑难解决方法(0)

Rails Mailer"Net :: OpenTimeout:execution expired"仅限生产服务器上的异常

我在Ubuntu 12.04 TLS VPS上使用Ruby MRI 2.0.0和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
}
Run Code Online (Sandbox Code Playgroud)

使用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
Run Code Online (Sandbox Code Playgroud)

输出:

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 …
Run Code Online (Sandbox Code Playgroud)

smtp ruby-on-rails actionmailer exception-notification

35
推荐指数
5
解决办法
3万
查看次数