how to set smpt server for our rails applicaion

hi i am using technoweenie-restful-authentication plug-in for authentication in my application. i want to send a activation link to the user's mail-id. for that i need to set the smpt server for our rails application, for that i added the follwing code in config/environment.rb file

ActionMailer::Base.delivery_method:smpt   ActionMailer::Base.smpt_settings = {   :address => "localhost",   :port => 25,   :authentication=> :login,   :user_name => "my_username",   :password => "my_password"   }

but when i try to run the server it gives the following errors

G:\my\MyMovies>ruby script/server => Booting Mongrel => Rails 2.3.3 application starting on http://0.0.0.0:3000 c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependenci es.rb:443:in `load_missing_constant': uninitialized constant ActionMailer (NameE rror)         from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_suppo rt/dependencies.rb:80:in `const_missing'         from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_suppo rt/dependencies.rb:92:in `const_missing'         from G:/my/MyMovies/config/environment.rb:43         from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/initializer.rb:111:i n `run'         from G:/my/MyMovies/config/environment.rb:9         from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `ge m_original_require'         from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `re quire'         from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_suppo rt/dependencies.rb:156:in `require'         from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_suppo rt/dependencies.rb:521:in `new_constants_in'         from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_suppo rt/dependencies.rb:156:in `require'         from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/commands/server.rb:8 4         from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `ge m_original_require'         from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `re quire'         from script/server:3

any anyone give me the procedure to add smpt server to my rails application is there any any code i need to add in my application to configure my application to the smpt server, if it is please tell me the procedure and which code i need to add.

regards, rajendra

Did you include these...

ActionMailer::Base.raise_delivery_errors = true ActionMailer::Base.perform_deliveries = true ActionMailer::Base.delivery_method = :smtp

hi i am using technoweenie-restful-authentication plug-in for authentication in my application. i want to send a activation link to the user's mail-id. for that i need to set the smpt server for our rails application, for that i added the follwing code in config/environment.rb file

It looks like you've got this towards the top of environment.rb, i.e before the bit that runs the initializer: you don't want this, the initializer is the thing that loads rails, so before it none of the rails framework (ActiveRecord, ActionMailer etc.) is loaded. You've also got a few typos in there.

Fred

Don't use environment.rb, use instead: "config/initializers/ action_mailer.rb". Set it to read:

ActionMailer::Base.delivery_method = :smtp

ActionMailer::Base.smtp_settings = {    :address => "localhost",    :port => 25,    :authentication=> :login,    :user_name => "my_username",    :password => "my_password"    }

NOTE 1: delivery_method = :smtp NOTE 2: smtp not smpt -- two places

What's the rational behind using initializers instead of environment files? We are (and have been for some time) setting the smtp options in the environment files with great success.

Cheers Simon

What's the rational behind using initializers instead of environment files? We are (and have been for some time) setting the smtp options in the
environment files with great success.

That rather than having environment.rb become a dumping ground you have a descriptively named set of files. Another incentive is that initializers run before your models are loaded (in production mode) whereas something at the bottom of environment.rb runs afterwards which can sometimes be problematic.

Fred