Ruby on rails 4 ROR中未从本地服务器发送邮件

Ruby on rails 4 ROR中未从本地服务器发送邮件,ruby-on-rails-4,Ruby On Rails 4,我尝试从本地服务器本地发送邮件,但服务器未启动。。。。。为什么会发生 控制器 developerNT.rb 错误“服务器未启动” 为什么会发生这种事。。。我不明白。。。。?任何建议都是你的问题: uninitialized constant CONFIG (NameError) 以下是用实际数据替换配置变量的解决方案: #config/environments/development.rb config.action_mailer.delivery_method = :smtp config.

我尝试从本地服务器本地发送邮件,但服务器未启动。。。。。为什么会发生

控制器 developerNT.rb 错误“服务器未启动”
为什么会发生这种事。。。我不明白。。。。?任何建议都是你的问题:

uninitialized constant CONFIG (NameError)
以下是用实际数据替换配置变量的解决方案:

#config/environments/development.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
    address: 'smtp.gmail.com',
    port: 587,
    domain: *************,
    authentication: 'plain',
    enable_starttls_auto: true,
    user_name: *************,
    password: ************  
}
我建议使用提供对ENV变量的访问权限,以便您可以将它们与CONFIG相同,但作为ENV使用

= form_for :forest, url:{:action =>"create"}, html:{:class => "form-horizontal" } do |f|
  %div.form-group
    = f.label :name, 'Name', {:class => 'col-lg-2 control-label'} 
    %div.col-lg-3
      = f.text_field :name, {:class => 'form-control', :placeholder => "Your Name"}
  %div.form-group
    = f.label :email, 'Email', {:class => 'col-lg-2 control-label'}
    %div.col-lg-3
      = f.text_field :email, {:class => 'form-control', :placeholder => "someone@example.com"}
  %div.form-group
    = f.label :phone, 'Phone', {:class => 'col-lg-2 control-label'}
    %div.col-lg-3
      = f.text_field :phone, {:class => 'form-control', :placeholder => "Mobile No"}
  %div.form-group
    = f.label :body, 'Body', {:class => 'col-lg-2 control-label'}
    %div.col-lg-3
      = f.text_area :body, {:class => 'form-control', :placeholder => "Your Message"}
  %div.form-group
    %div.col-lg-offset-2.col-lg-10
      = f.submit :class => "btn btn-primary", :value => "Contact Us"
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = 
{
address: 'smtp.gmail.com',
port: 587,
domain: CONFIG[:mail_domain],
authentication: 'plain',
enable_starttls_auto: true,
user_name: CONFIG[:mail_username],
password: CONFIG[:mail_password]   
}
/Users/T1/forestBankPakistan/config/environments/development.rb:24:in `block in <top (required)>': uninitialized constant CONFIG (NameError)
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/railtie/configurable.rb:24:in `class_eval'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/railtie/configurable.rb:24:in `configure'
    from /Users/T1/forestBankPakistan/config/environments/development.rb:1:in `<top (required)>'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/engine.rb:591:in `block (2 levels) in <class:Engine>'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/engine.rb:590:in `each'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/engine.rb:590:in `block in <class:Engine>'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `run'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/T1/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
    from /Users/T1/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
    from /Users/T1/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:210:in `block (2 levels) in each_strongly_connected_component_from'
    from /Users/T1/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
    from /Users/T1/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:209:in `block in each_strongly_connected_component_from'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/initializable.rb:44:in `each'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/initializable.rb:44:in `tsort_each_child'
    from /Users/T1/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:203:in `each_strongly_connected_component_from'
    from /Users/T1/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
    from /Users/T1/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:180:in `each'
    from /Users/T1/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
    from /Users/T1/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/application.rb:215:in `initialize!'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/T1/forestBankPakistan/config/environment.rb:5:in `<top (required)>'
    from /Users/T1/forestBankPakistan/config.ru:3:in `block in <main>'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
    from /Users/T1/forestBankPakistan/config.ru:in `new'
    from /Users/T1/forestBankPakistan/config.ru:in `<main>'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/commands/server.rb:48:in `app'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/commands/server.rb:75:in `start'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/commands.rb:76:in `block in <top (required)>'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/commands.rb:71:in `tap'
    from /Users/T1/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/commands.rb:71:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'
uninitialized constant CONFIG (NameError)
#config/environments/development.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
    address: 'smtp.gmail.com',
    port: 587,
    domain: *************,
    authentication: 'plain',
    enable_starttls_auto: true,
    user_name: *************,
    password: ************  
}