about summary refs log tree commit diff
path: root/config/environments
diff options
context:
space:
mode:
authorStarfall <us@starfall.systems>2022-11-12 10:09:41 -0600
committerStarfall <us@starfall.systems>2022-11-12 10:11:39 -0600
commitb07b6b9f339b604f9af150eb10ac1486eca8f189 (patch)
tree512943f7488b1fdb7d7c5d87cc039ea2f1886292 /config/environments
parentb96b336a7871b5e88da8f308116e8f0ca7827132 (diff)
parent81b1d32d5b618daa4003b8de8292ae4dd3e656f6 (diff)
Merge remote-tracking branch 'glitch/main'
Diffstat (limited to 'config/environments')
-rw-r--r--config/environments/production.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/config/environments/production.rb b/config/environments/production.rb
index d6f967e74..fedfe5efb 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -97,6 +97,20 @@ Rails.application.configure do
   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'],
@@ -106,7 +120,8 @@ Rails.application.configure do
     :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_auto => ENV['SMTP_ENABLE_STARTTLS_AUTO'] != 'false',
+    :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',
   }