Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8814631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:10:35+00:00 2026-06-14T04:10:35+00:00

Hi I have my rails app on heroku and github and am currently using

  • 0

Hi I have my rails app on heroku and github and am currently using a mailer in my app:

ActionMailer::Base.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => 587,
  :user_name            => "myemail@gmail.com",
  :password             => "PasswordShouldGoHere",
  :authentication       => "plain",
  :enable_starttls_auto => true
}

I don’t want my email and password to be visible on my github account, since people can just log in and steal my info. However, if I put a fake password, then my app will give me an error on heroku when the mailer is supposed to deliver. I know I can just push up the real email and password to heroku first and then edit it and put the fake password on my github account, but is there a better way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:10:37+00:00Added an answer on June 14, 2026 at 4:10 am

    Like other people said, you can achieve this security by using ENV variables. Here’s how to do it:

    config.action_mailer.smtp_settings = {
      user_name: ENV["MAILER_EMAIL"],
      password: ENV["MAILER_PASSWORD"]
    }
    

    Now, in production (Heroku), all you have to do is follow this guide. It basically amounts to opening your console and typing this:

    heroku config:set MAILER_EMAIL=email@example.com MAILER_PASSWORD=password
    

    In development, you can create a file inside the config/initializers folder with a suggestive name like app_env_vars.rb. Inside it, place the following:

    ENV['MAILER_EMAIL'] = 'email@example.com'
    ENV['MAILER_PASSWORD'] = 'password'
    

    To prevent this newly created file from being pushed into your source control, you should add it to your .gitignore:

    /config/initializers/app_env_vars.rb
    

    However, there’s a problem because initializer files are only loaded after the environment, so there’s one last thing to do. Go to your environment.rb file and add the following before the Yourapp::Application.initialize!:

    # Load the app's custom environment variables here, before environments/*.rb
    app_env_vars = File.join(Rails.root, 'config', 'initializers', 'app_env_vars.rb')
    load(app_env_vars) if File.exists?(app_env_vars)
    

    You’re done!

    However, if you find all of this configuration a hassle, then I recommend using the Figaro gem. It does everything I described and more!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rails app running on Heroku. I am using paperclip for some
I have a Rails 3 app I'm developing with a team using Git/Github and
I have a rails app that runs on Heroku using their standard postgres database
I have an existing Rails app on GitHub and deployed on Heroku. I'm trying
I'm using Heroku and have a Rails app that is stable (production env), so
I have a Rails app on Heroku using the Postgres 9 beta. I've tried
I have a Rails app deployed on Heroku with the Heroku scheduler add-on successfully
I have a Rails app hosted in Heroku. If I go the the site
I have a Rails app running Mongoid on Heroku and I need to set
I have a Rails 3.2 app that I'm deploying on the Heroku Cedar stack.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.