There are lots of other variations on this... see this blog post for more ideas:
http://www.simonecarletti.com/blog/2009/06/capistrano-and-database-yml
Here a start...
Add this into your production.rb environment file:
ActionMailer::Base.smtp_settings = File.expand_path(File.join(RAILS_ROOT, 'config', 'actionmailer.yml'))
And in a capistrano task, you can do something like this:
desc "Generate actionmailer.yml file"
task :generate_actionmailer_yml, :roles=>:app do
secret_password = Capistrano::CLI.ui.ask "Enter your secret mail password:"
template = File.read("config/deploy/actionmailer.yml.erb")
buffer = ERB.new(template).result(binding)
put buffer, "#{shared_path}/config/actionmailer.yml"
end
desc "Link actionmailer.yml from shared"
task :link_actionmailer_yml, :roles=>:app do
run "rm -f #{current_path}/config/actionmailer.yml && ln -s #{shared_path}/config/actionmailer.yml #{current_path}/config/actionmailer.yml"
end
after "deploy:finalize_update", "deploy:link_actionmailer_yml"
Then, you create a template actionmailer.yml.erb file:
address: "my.smtp.com"
port: 587
authentication: :plain
user_name: "[email protected]"
password: <%= secret_password %>