我在的ActionMailer收到錯誤時,我的工作人員正試圖發送電子郵件的ActionMailer Rails中未發送郵件3.1.1
Errno::ECONNREFUSED
Connection refused - connect(2)
/Users/bhushan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/smtp.rb:546:in `initialize'
/Users/bhushan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/smtp.rb:546:in `open'
/Users/bhushan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/smtp.rb:546:in `tcp_socket'
/Users/bhushan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/smtp.rb:555:in `block in do_start'
/Users/bhushan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/timeout.rb:58:in `timeout'
/Users/bhushan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/timeout.rb:89:in `timeout'
/Users/bhushan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/smtp.rb:555:in `do_start'
/Users/bhushan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/smtp.rb:525:in `start'
/Users/bhushan/.rvm/gems/ruby-1.9.2-p290/gems/mail-2.3.0/lib/mail/network/delivery_methods/smtp.rb:128:in `deliver!'
/Users/bhushan/.rvm/gems/ruby-1.9.2-p290/gems/mail-2.3.0/lib/mail/message.rb:1989:in `do_delivery'
/Users/bhushan/.rvm/gems/ruby-1.9.2-p290/gems/mail-2.3.0/lib/mail/message.rb:230:in `block in deliver'
/Users/bhushan/.rvm/gems/ruby-1.9.2-p290/gems/actionmailer-3.1.1/lib/action_mailer/base.rb:432:in `block in deliver_mail'
/Users/bhushan/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/notifications.rb:53:in `block in instrument'
/Users/bhushan/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/Users/bhushan/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/notifications.rb:53:in `instrument'
/Users/bhushan/.rvm/gems/ruby-1.9.2-p290/gems/actionmailer-3.1.1/lib/action_mailer/base.rb:430:in `deliver_mail'
/Users/bhushan/.rvm/gems/ruby-1.9.2-p290/gems/mail-2.3.0/lib/mail/message.rb:230:in `deliver'
/Users/bhushan/betterlabs_projects/companyplus_beta/cp_frontend/app/workers/set_crawling.rb:29:in `perform'
我在初始化文件爲setup_mail.rb具有SMTP設置
ActionMailer::Base.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: 'betterlabs.net',
user_name: '[email protected]',
password:
authentication: 'plain',
enable_starttls_auto: true
}
和我的郵件方法
def send_email(email)
begin
# attachments['result.csv'] = File.read(file)
mail(to: "[email protected]", subject: "hey")
puts "====Mail Sent===="
rescue Exception=>e
puts e.inspect
end
end
development.rb
config.action_mailer.delivery_method = :smtp
任何有關可能會出錯的信息?謝謝。
我假設你已將'ActionMailer :: Base.delivery_method'設置爲':smtp'? –
我有config.action_mailer.delivery_method =:smtp in development.rb –
您可以直接連接到smtp.gmail.com:587,例如:通過telnet? – Thilo