ActionMailer - Net :: OpenTimeout:执行过期

时间:2015-09-22 04:58:18

标签: ruby-on-rails ruby email timeout

在rails 4.2.2和ubuntu 12.04中,我正在尝试使用https://gist.github.com/the-teacher/6dfe0b2050dfa7092ccd实现电子邮件功能,现在当我通过rails console尝试时邮件没有发送,错误就像,

Net::OpenTimeout: execution expired
from /home/shruthi/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/smtp.rb:541:in `initialize'
from /home/shruthi/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/smtp.rb:541:in `open'
from /home/shruthi/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/smtp.rb:541:in `tcp_socket'
from /home/shruthi/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/smtp.rb:551:in `block in do_start'
from /home/shruthi/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/timeout.rb:91:in `block in timeout'
from /home/shruthi/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/timeout.rb:101:in `call'
from /home/shruthi/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/timeout.rb:101:in `timeout'
from /home/shruthi/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/smtp.rb:550:in `do_start'
from /home/shruthi/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/smtp.rb:520:in `start'
from /home/shruthi/.rvm/gems/ruby-2.1.2/gems/mail-2.6.3/lib/mail/network/delivery_methods/smtp.rb:112:in `deliver!'
from /home/shruthi/.rvm/gems/ruby-2.1.2/gems/mail-2.6.3/lib/mail/message.rb:2141:in `do_delivery'
from /home/shruthi/.rvm/gems/ruby-2.1.2/gems/mail-2.6.3/lib/mail/message.rb:236:in `block in deliver'
from /home/shruthi/.rvm/gems/ruby-2.1.2/gems/actionmailer-4.2.2/lib/action_mailer/base.rb:543:in `block in deliver_mail'
from /home/shruthi/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.2/lib/active_support/notifications.rb:164:in `block in instrument'
from /home/shruthi/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.2/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
from /home/shruthi/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.2/lib/active_support/notifications.rb:164:in `instrument'
from /home/shruthi/.rvm/gems/ruby-2.1.2/gems/actionmailer-4.2.2/lib/action_mailer/base.rb:541:in `deliver_mail'
from /home/shruthi/.rvm/gems/ruby-2.1.2/gems/mail-2.6.3/lib/mail/message.rb:236:in `deliver'
from /home/shruthi/.rvm/gems/ruby-2.1.2/gems/actionmailer-4.2.2/lib/action_mailer/message_delivery.rb:85:in `deliver_now'
from /home/shruthi/Projects/POC/file_system/app/models/email.rb:4:in `deliver_welcome_mail_to_user'
from (irb):2
from /home/shruthi/.rvm/gems/ruby-2.1.2/gems/railties-4.2.2/lib/rails/commands/console.rb:110:in `start'
from /home/shruthi/.rvm/gems/ruby-2.1.2/gems/railties-4.2.2/lib/rails/commands/console.rb:9:in `start'
from /home/shruthi/.rvm/gems/ruby-2.1.2/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:68:in `console'
from /home/shruthi/.rvm/gems/ruby-2.1.2/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/shruthi/.rvm/gems/ruby-2.1.2/gems/railties-4.2.2/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'

在development.rb中,

config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true 
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
 :address => "smtp.yandex.ru",
 :port => 25,
 :domain => "yandex.com",
 :authentication => :plain,
 :user_name => "shruthi@yandex.com",
 :password => "sss123@"
}

在mailer.rb中,

class GeneralMailer < ActionMailer::Base

 default :from=> "shruthi@yandex.com"

 def welcome_email(user, password)
  @user = user
  @password = password
  mail(:to =>"shruthi@yopmail.com", :subject =>"Welcome") do |format|
  format.html { render :partial => "/emails/welcome", :layout=>false }
  end
 end

end

在config / settings / development.yml中,

mailer:
  service: smtp
  host: localhost:3000

sandmail:
  location:  '/usr/sbin/sendmail'
  arguments: '-i -t'

smtp:
  address: 'smtp.yandex.ru'
  domain:  'yandex.ru'
  port:    25

  email:   'shruthi@yandex.com'
  password: sss123@
  authentication: plain

请帮我解决此电子邮件问题。

0 个答案:

没有答案