You need to store your configuration in a file excluded from Git but shared between deployments. Assuming you are using Capistrano 3, it would be something like this:
1) On your server create a file shared/config/smtp.yml
(using YAML is not something crucial, but it's just cleaner for configs) in Capistrano root folder with the following content:
user: user@gmail.com
pass: your_password
address: smtp.gmail.com
port: 587
2) Add this file to your linked_files
in config/deploy.rb
(ideally, config/database.yml
should be stored this way too):
set :linked_files, %w{config/database.yml config/smtp.yml}
3) Read SMTP config in production.rb
from config/smtp.yml
.
4) You can also have config/smtp.yml
locally for your development environment, but don't forget to add it to your .gitignore
then.