From bf2ed3077a2b740ad5241b1fd00242a119a7893a Mon Sep 17 00:00:00 2001 From: lisa3711 Date: Tue, 23 Apr 2024 14:41:39 -0400 Subject: [PATCH 1/4] fixes issue #344-mailer --- config/environments/production.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index edd51b2c..32e91289 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -72,6 +72,15 @@ # Store the base url from where request is received. config.action_mailer.default_url_options = { host: ENV['APP_PORTFOLIO_PRODUCTION_MAILER_URL'] } + #updated for tls and sendmail + config.action_mailer.smtp_settings = { + enable_starttls_auto: true, + port: 25, + # 'ca_file' is the path to the certificate authority file. + # In our case, it's a self-signed certificate. This tells Rails to trust this specific certificate. + ca_file: '/etc/ssl/certs/sendmail.pem' + } + # 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. # config.action_mailer.raise_delivery_errors = false @@ -99,9 +108,6 @@ # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false - # Needed for mail to work in production - config.action_mailer.smtp_settings = { enable_starttls_auto: false } - # Change the Uglifier parsing engine config.assets.js_compressor = Uglifier.new(harmony: true) end From 157469e2f6ab1f3dd2b954956fc79c72413ba6d2 Mon Sep 17 00:00:00 2001 From: lisa3711 Date: Tue, 23 Apr 2024 14:49:34 -0400 Subject: [PATCH 2/4] fix rubocop --- config/environments/production.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 32e91289..6bdc451d 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -72,7 +72,7 @@ # Store the base url from where request is received. config.action_mailer.default_url_options = { host: ENV['APP_PORTFOLIO_PRODUCTION_MAILER_URL'] } - #updated for tls and sendmail + # updated for tls and sendmail config.action_mailer.smtp_settings = { enable_starttls_auto: true, port: 25, From 63f6a8878bb218e8af7df8f405de3f4d467f08fc Mon Sep 17 00:00:00 2001 From: Thomas Scherz Date: Tue, 23 Jul 2024 13:45:03 -0400 Subject: [PATCH 3/4] Fixes mailer settings to include environment variable. --- .env.development | 3 +++ .env.test | 3 +++ config/environments/production.rb | 9 ++++++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.env.development b/.env.development index 24dfe4e3..d257f5f0 100644 --- a/.env.development +++ b/.env.development @@ -15,3 +15,6 @@ APP_PORTFOLIO_PRODUCTION_MAILER_URL=localhost:3000 #reCaptcha settings APP_PORTFOLIO_reCAPTCHA_SITE_KEY="" APP_PORTFOLIO_reCAPTCHA_SECRET_KEY="" + +#mailer settings +MAIL_SMTP_ADDRESS='localhost' diff --git a/.env.test b/.env.test index 56885107..a62888ba 100644 --- a/.env.test +++ b/.env.test @@ -11,3 +11,6 @@ APP_PORTFOLIO_DATABASE_TIMEOUT=5000 APP_PORTFOLIO_DATABASE_USERNAME= APP_PORTFOLIO_PRODUCTION_MAILER_URL=localhost:3000 + +#mailer settings +MAIL_SMTP_ADDRESS='localhost' diff --git a/config/environments/production.rb b/config/environments/production.rb index 6bdc451d..7d6f22b7 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -65,16 +65,19 @@ # config.active_job.queue_adapter = :resque # config.active_job.queue_name_prefix = "application_portfolio_#{Rails.env}" + # Configure Secure Sendmail mailer config.action_mailer.raise_delivery_errors = true - config.action_mailer.perform_caching = false - config.action_mailer.default_options = { from: 'uclappdev@uc.edu' } + config.mailer_from = 'uclappdev@uc.edu' + config.action_mailer.delivery_method = :smtp # Store the base url from where request is received. config.action_mailer.default_url_options = { host: ENV['APP_PORTFOLIO_PRODUCTION_MAILER_URL'] } - # updated for tls and sendmail config.action_mailer.smtp_settings = { enable_starttls_auto: true, + # 'address' specifies the address of the server that will handle email sending. + address: ENV['MAIL_SMTP_ADDRESS'], + # 'port' specifies which port to use on the SMTP server. port: 25, # 'ca_file' is the path to the certificate authority file. # In our case, it's a self-signed certificate. This tells Rails to trust this specific certificate. From a1ef8f62bac368ed7ee4874dbc6b7b3a1b49b640 Mon Sep 17 00:00:00 2001 From: Thomas Scherz Date: Tue, 23 Jul 2024 13:54:14 -0400 Subject: [PATCH 4/4] Updates rexml version --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 0fa8bf6f..b6d70f65 100644 --- a/Gemfile +++ b/Gemfile @@ -36,7 +36,7 @@ gem 'rails-controller-testing' # Use rubocop for static code analysis gem 'rubocop' # bundler audit -gem 'rexml', '>= 3.2.7' +gem 'rexml', '>= 3.3.2' gem 'rubocop-rails', require: false gem 'rubocop-rspec', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 8d0cc90b..5682f0ab 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -264,7 +264,7 @@ GEM responders (3.1.1) actionpack (>= 5.2) railties (>= 5.2) - rexml (3.3.1) + rexml (3.3.2) strscan rspec-core (3.13.0) rspec-support (~> 3.13.0) @@ -432,7 +432,7 @@ DEPENDENCIES rails-controller-testing rb-readline recaptcha - rexml (>= 3.2.7) + rexml (>= 3.3.2) rspec-rails (~> 4.1.0) rspec_junit_formatter rubocop