Skip to content

Instantly share code, notes, and snippets.

@overdrivemachines
Last active November 11, 2022 08:16
Show Gist options
  • Save overdrivemachines/3eac34ded2cc6e5b50996e25429762fb to your computer and use it in GitHub Desktop.
Save overdrivemachines/3eac34ded2cc6e5b50996e25429762fb to your computer and use it in GitHub Desktop.
Send emails in production environment Ruby on Rails

Generate Gmail App Password

Go to https://myaccount.google.com/apppasswords and generate an App Password

Save App Password

In terminal open the rails credentials

rails credentials:edit

Save the following info:

email:
  user: myemail@gmail.com
  password: PwdFromPrevStep

production.rb

In production.rb, add the following

config.require_master_key = true
config.action_mailer.delivery_method = :smtp
host = 'yourhotelhelper.com'
config.action_mailer.default_url_options = { host: host }
config.action_mailer.smtp_settings = {
  port: 587,
  address: 'smtp.gmail.com',
  user_name: Rails.application.credentials.dig(:email, :user),
  password: Rails.application.credentials.dig(:email, :password),
  authentication: :plain,
  enable_starttls_auto: true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment