From 2e0d0bfd7f0ba80d6ae8e2213cfc67fd089588a3 Mon Sep 17 00:00:00 2001 From: baarkerlounger <5101747+baarkerlounger@users.noreply.github.com> Date: Wed, 8 Dec 2021 10:31:12 +0000 Subject: [PATCH] Fix action mailer on gov paas (#153) * Set action mailer host to env vars * Inject env var * Fix template * Single env var --- .github/workflows/pipeline.yml | 2 ++ app/views/devise/mailer/_password_change_initial.html.erb | 4 ++-- config/environments/production.rb | 2 ++ config/environments/sandbox.rb | 2 ++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index b83258ce5..6aab30e77 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -106,6 +106,7 @@ jobs: APP_NAME: dluhc-core CORE_EMAIL_USERNAME: ${{ secrets.CORE_EMAIL_USERNAME }} CORE_EMAIL_PASSWORD: ${{ secrets.CORE_EMAIL_PASSWORD }} + APP_HOST: ${{ secrets.APP_HOST }} run: | cf7 api $CF_API_ENDPOINT cf7 auth @@ -114,4 +115,5 @@ jobs: cf7 set-env $APP_NAME API_KEY $API_KEY cf7 set-env $APP_NAME CORE_EMAIL_USERNAME $CORE_EMAIL_USERNAME cf7 set-env $APP_NAME CORE_EMAIL_PASSWORD $CORE_EMAIL_PASSWORD + cf7 set-env $APP_NAME APP_HOST $APP_HOST cf7 push --strategy rolling diff --git a/app/views/devise/mailer/_password_change_initial.html.erb b/app/views/devise/mailer/_password_change_initial.html.erb index 6645c7c77..39363dc53 100644 --- a/app/views/devise/mailer/_password_change_initial.html.erb +++ b/app/views/devise/mailer/_password_change_initial.html.erb @@ -1,6 +1,6 @@
Hello <%= @resource.name %>!
-An account has been created for you to submit CORE data on behalf of @resource.organisation.
+An account has been created for you to submit CORE data on behalf of <%= @resource.organisation %>.
-Your username is <% @resource.email %>, use the link below to set your password. +
Your username is <%= @resource.email %>, use the link below to set your password.
<%= govuk_link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %>
diff --git a/config/environments/production.rb b/config/environments/production.rb index 45b256ef5..dcb239817 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -58,6 +58,8 @@ Rails.application.configure do config.action_mailer.perform_caching = false + config.action_mailer.default_url_options = { host: ENV['APP_HOST'], port: 3000 } + # 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 diff --git a/config/environments/sandbox.rb b/config/environments/sandbox.rb index 45b256ef5..dcb239817 100644 --- a/config/environments/sandbox.rb +++ b/config/environments/sandbox.rb @@ -58,6 +58,8 @@ Rails.application.configure do config.action_mailer.perform_caching = false + config.action_mailer.default_url_options = { host: ENV['APP_HOST'], port: 3000 } + # 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