use .env and support SMTP configuration
This commit is contained in:
parent
a402d14510
commit
e082b0da6e
|
@ -4,6 +4,9 @@
|
|||
.byebug_history
|
||||
|
||||
/config/database.yml
|
||||
.env
|
||||
.env.production
|
||||
.env.development
|
||||
|
||||
/coverage
|
||||
|
||||
|
|
1
Gemfile
1
Gemfile
|
@ -5,6 +5,7 @@ source "https://rubygems.org"
|
|||
gem "i18n-js", "4.0"
|
||||
gem "rails", "~> 6.1"
|
||||
gem "rails-i18n", "~> 7.0"
|
||||
gem "dotenv-rails", "~> 2.8"
|
||||
|
||||
gem "cssbundling-rails", "~> 1.2"
|
||||
gem "jsbundling-rails", "~> 1.1"
|
||||
|
|
|
@ -130,6 +130,10 @@ GEM
|
|||
devise (>= 4.8.0)
|
||||
diff-lcs (1.5.0)
|
||||
docile (1.4.0)
|
||||
dotenv (2.8.1)
|
||||
dotenv-rails (2.8.1)
|
||||
dotenv (= 2.8.1)
|
||||
railties (>= 3.2)
|
||||
dry-core (1.0.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
zeitwerk (~> 2.6)
|
||||
|
@ -505,6 +509,7 @@ DEPENDENCIES
|
|||
devise (~> 4.9)
|
||||
devise-async
|
||||
devise-i18n
|
||||
dotenv-rails (~> 2.8)
|
||||
dry-initializer (~> 3.1)
|
||||
dry-types (~> 1.7)
|
||||
factory_bot_rails
|
||||
|
|
|
@ -73,8 +73,40 @@ Rails.application.configure do
|
|||
# config.active_job.queue_name_prefix = "justask_#{Rails.env}"
|
||||
config.action_mailer.perform_caching = false
|
||||
|
||||
# Use sendmail
|
||||
config.action_mailer.delivery_method = :sendmail
|
||||
config.action_mailer.default_options[:reply_to] = ENV['SMTP_REPLY_TO'] if ENV['SMTP_REPLY_TO'].present?
|
||||
config.action_mailer.default_options[:return_path] = ENV['SMTP_RETURN_PATH'] if ENV['SMTP_RETURN_PATH'].present?
|
||||
|
||||
enable_starttls = nil
|
||||
enable_starttls_auto = nil
|
||||
|
||||
case ENV['SMTP_ENABLE_STARTTLS']
|
||||
when 'always'
|
||||
enable_starttls = true
|
||||
when 'never'
|
||||
enable_starttls = false
|
||||
when 'auto'
|
||||
enable_starttls_auto = true
|
||||
else
|
||||
enable_starttls_auto = ENV['SMTP_ENABLE_STARTTLS_AUTO'] != 'false'
|
||||
end
|
||||
|
||||
config.action_mailer.smtp_settings = {
|
||||
port: ENV['SMTP_PORT'],
|
||||
address: ENV['SMTP_SERVER'],
|
||||
user_name: ENV['SMTP_LOGIN'].presence,
|
||||
password: ENV['SMTP_PASSWORD'].presence,
|
||||
domain: ENV['SMTP_DOMAIN'] || ENV['LOCAL_DOMAIN'],
|
||||
authentication: ENV['SMTP_AUTH_METHOD'] == 'none' ? nil : ENV['SMTP_AUTH_METHOD'] || :plain,
|
||||
ca_file: ENV['SMTP_CA_FILE'].presence || '/etc/ssl/certs/ca-certificates.crt',
|
||||
openssl_verify_mode: ENV['SMTP_OPENSSL_VERIFY_MODE'],
|
||||
enable_starttls: enable_starttls,
|
||||
enable_starttls_auto: enable_starttls_auto,
|
||||
tls: ENV['SMTP_TLS'].presence && ENV['SMTP_TLS'] == 'true',
|
||||
ssl: ENV['SMTP_SSL'].presence && ENV['SMTP_SSL'] == 'true',
|
||||
read_timeout: 20,
|
||||
}
|
||||
|
||||
config.action_mailer.delivery_method = ENV.fetch('SMTP_DELIVERY_METHOD', 'sendmail').to_sym
|
||||
|
||||
# Ignore bad email addresses and do not raise email delivery errors.
|
||||
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
||||
|
|
Loading…
Reference in New Issue