Skip to content

Commit

Permalink
fixes issue #344-mailer (#360)
Browse files Browse the repository at this point in the history
* fixes issue #344-mailer

* fix rubocop

* Fixes mailer settings to include environment variable.

* Updates rexml version

---------

Co-authored-by: Thomas Scherz <[email protected]>
  • Loading branch information
haitzlm and Thomas Scherz authored Jul 23, 2024
1 parent a423a62 commit da9b4dd
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -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'
3 changes: 3 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -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'
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
19 changes: 14 additions & 5 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,24 @@
# 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: '[email protected]' }
config.mailer_from = '[email protected]'
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.
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.
Expand Down Expand Up @@ -99,9 +111,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

0 comments on commit da9b4dd

Please sign in to comment.