使用Ruby on Rail设置向朋友发送电子邮件时出错

时间:2014-12-13 06:08:37

标签: ruby-on-rails ruby ruby-on-rails-3

任何人都可以帮我解决这个问题。我想在我的网页上使用ROR设置电子邮件服务。当我输入命令" rails生成邮件用户邮件"在我的命令提示中,我收到了以下错误。

我使用的是rails-4和ru​​by-1.9.3

Error:
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionmailer-4.1.7/lib/action_mailer/base.rb
:553:in `method_missing': undefined method `server_settings=' for ActionMailer::
Base:Class (NoMethodError)
        from c:/Site/emailid1/config/environment.rb:7:in `<top (required)>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.1.7/lib/rails/applic
ation.rb:276:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.1.7/lib/rails/applic
ation.rb:276:in `require_environment!'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.1.7/lib/rails/comman
ds/commands_tasks.rb:147:in `require_application_and_environment!'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.1.7/lib/rails/comman
ds/commands_tasks.rb:133:in `generate_or_destroy'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.1.7/lib/rails/comman
ds/commands_tasks.rb:51:in `generate'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.1.7/lib/rails/comman
ds/commands_tasks.rb:40:in `run_command!'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.1.7/lib/rails/comman
ds.rb:17:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

我已经使用以下代码在config / environment.rb中设置了我的environment.rb文件。

 ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.server_settings = {
   :address => "smtp.tutorialspoint.com",
   :port => 25,
   :domain => "http://localhost:3000",
   :authentication => :login,
   :user_name => "w5call.w5rtc@gmail.com",
   :password => "w5rtc123@",
}
ActionMailer::Base.default_content_type = "text/plain"

我在localhost中测试请帮我检查上面的每个哈希值设置是否有错,请提供正确的哈希值并解决上述错误。

1 个答案:

答案 0 :(得分:0)

1:您关注的文章太旧了 tutorialspoint 使用此剪辑

ActionMailer::Base.smtp_settings = {  
 :address              => "smtp.gmail.com",  
 :port                 => 587,  
 :domain               => "gmail.com",  
 :user_name            => "email@gmail.com",  
 :password             => "*************",  
 :authentication       => "plain"

}

2:http://railscasts.com/episodes/206-action-mailer-in-rails-3?view=asciicast