Jets Rails Email Configuration Mailgun
Here’s an example on how to set up email with Mailgun.
Gemfile:
gem 'mailgun-ruby'
config/environments/production.rb
require 'railgun/mailer'
require 'railgun/message'
Rails.application.configure do
config.action_mailer.show_previews = false # default: false
config.action_mailer.raise_delivery_errors = true
config.action_mailer.add_delivery_method :mailgun, Railgun::Mailer
config.action_mailer.delivery_method = :mailgun
config.action_mailer.mailgun_settings = {
api_key: ENV['MAILGUN_API_KEY'],
domain: ENV['MAILGUN_DOMAIN'],
}
end
config/jets/env/.env
RAILS_ENV=production
MAILGUN_API_KEY=SSM # /dev/demo/MAILGUN_API_KEY => ADJ23JOXELX
MAILGUN_DOMAIN=SSM # /dev/demo/MAILGUN_DOMAIN => mydomain.com
The example above maps to an SSM parameter value with JETS_ENV=dev
, the default. If JETS_ENV=prod
then the SSM parameter would be /prod/demo/<NAME>
.
Also, regardless of the value of JETS_ENV, RAILS_ENV=production
should always used.