当我的工作人员尝试发送电子邮件时,我在 ActionMailer 中遇到错误
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'
我在具有 smtp 设置的初始化程序中有一个文件 setup_mail.rb
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
发展.rb
config.action_mailer.delivery_method = :smtp
对可能出什么问题的任何见解?谢谢。
最佳答案
检查您在 :from
类的开头定义的 ActionMailer
键
关于ruby - ActionMailer 不发送邮件在 Rails 3.1.1,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8168974/