You can save your email credentials in another config / email.credentials.yml file:
host: ... username: ... password: ... ...
and in the environment.rb file just load them (for example):
YAML.load_file("#{Rails.root}/config/email.credentials.yml")['username']
then you should mention the credential file in the .gitignore file.
In addition, if you deploy the application on multiple servers, you can check if the file exists in the initializer and otherwise cause an error. This way you will make sure that the application does not start if there is no mail configuration file.
source share