Skip to content

Send confirmation emails with a copy of answers using SES#2124

Open
stephencdaly wants to merge 11 commits into
mainfrom
add-ses-template-for-confirmation-email-with-answers
Open

Send confirmation emails with a copy of answers using SES#2124
stephencdaly wants to merge 11 commits into
mainfrom
add-ses-template-for-confirmation-email-with-answers

Conversation

@stephencdaly
Copy link
Copy Markdown
Contributor

@stephencdaly stephencdaly commented May 27, 2026

What problem does this pull request solve?

Trello card: https://trello.com/c/hCWhyMOm

Send a confirmation email using Amazon SES containing a copy of the user's answers if they have signed in with One Login and asked for a copy of their answers.

If they have not asked for a copy of their answers, continue sending the confirmation email using Notify. However, the mailer for sending with SES accepts an option for including a copy of the answers or not, so switching over down the line to use SES for all confirmation emails should be easy.

Email styling

We're not currently explicitly specifying the style for headings, as per the submission email. We probably should, especially as we're now introducing h4s. I'd welcome comments on the best way to do this - but might raise a follow up PR to look at this as this PR is already very big.

Testing

You'll need to configure your GOV.UK One Login test service (ask me how if you haven't)

Then run locally, in an AWS shell for the dev-readonly role with the following environment variables:

gds aws forms-dev-readonly --shell

SETTINGS__GOVUK_ONE_LOGIN__CLIENT_ID=your-client-id SETTINGS__GOVUK_ONE_LOGIN__PRIVATE_KEY=your-base64-encoded-private-key ASSUME_DEV_IAM_ROLE=true bundle exec rails s
Screenshot 2026-05-27 at 12 08 13 Screenshot 2026-05-27 at 12 08 25

Things to consider when reviewing

  • Ensure that you consider the wider context.
  • Does it work when run on your machine?
  • Is it clear what the code is doing?
  • Do the commit messages explain why the changes were made?
  • Are there all the unit tests needed?
  • Do the end to end tests need updating before these changes will pass?
  • Has all relevant documentation been updated?

@stephencdaly stephencdaly force-pushed the add-ses-template-for-confirmation-email-with-answers branch 3 times, most recently from 9a2cd03 to fcffab6 Compare May 27, 2026 10:01
@stephencdaly stephencdaly force-pushed the add-ses-template-for-confirmation-email-with-answers branch 2 times, most recently from 2512ffd to 5eb6b4d Compare May 27, 2026 10:59
@stephencdaly stephencdaly changed the title Add ses template for confirmation email with answers Send confirmation emails with a copy of answers using SES May 27, 2026
@stephencdaly stephencdaly marked this pull request as ready for review May 27, 2026 11:19
@@ -0,0 +1,29 @@
class AwsSesSubmissionConfirmationMailer < ApplicationMailer
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: do we need to say "AwsSes" in the class name - there's nothing in this class implementation that's specific to AWS SES

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we do so with other mailer names - but really is irrelevant.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created a card for using SES for all confirmation emails and added a task to remove the prefixes when we're no longer sending using Notify too https://trello.com/c/GfBTJbNL/3581-use-ses-to-send-all-confirmation-emails

Comment thread app/views/aws_ses_submission_confirmation_mailer/_content.html.erb
Initially, we will just send confirmation emails with a copy of the
user's answers using SES, but we should switch to using it for all
confirmation emails when we're confident that it works as expected.

The mailer accepts a `include_copy_of_answers` parameter to allow
for sending confirmation emails without a copy of the user's answers.

The `_content` partials exist because we repeat the same
content in English and Welsh if the form was filled out using Welsh.
Allow specifying the heading level for the answer content in the
formatter so we can use h4 for the confirmation email.
@stephencdaly stephencdaly force-pushed the add-ses-template-for-confirmation-email-with-answers branch from 5eb6b4d to cd7fe6f Compare May 27, 2026 15:29
Comment thread app/models/submission.rb Outdated
Comment thread app/models/repeatable_step.rb Outdated
Construct the question/answer section in the Welsh part of the
confirmation email using the question text from the Welsh form
document saved on the submission.
We don't attach the uploaded file for file upload questions to the
confirmation email with a copy of the answers, and so want to display
different content. We also want to display the filename that the user
uploaded the file with, rather than the filename with the submission
reference and any suffix that we send in the submission email to
form processors.
We now store the Welsh form document on the submission for forms that
have a submission_locale of "cy". We no longer need to retrieve the
form document from forms-admin when sending the confirmation email
and can instead read it from the submission.
Accept an include_copy_of_answers parameter to
SendConfirmationEmailJob. If this is set to true, use SES to send the
confirmation email, including the answer in the email.

In future we'll use SES to send all confirmation emails, but we want
to make sure this is working correctly just for emails that include a
copy of the answers first.
If the user has asked to receive a copy of their answers, enqueue
the confirmation email job using the email address stored on the
session after they logged in the GOV.UK One Login, and with
include_copy_of_answers set to true.
ActiveJob sets the locale for jobs to be the locale at the time of
enqueuing. Force the job to use the English locale, as we send
multilingual emails if the user submitted answers in Welsh.
Using the module constant is preferred over using a symbol
@stephencdaly stephencdaly force-pushed the add-ses-template-for-confirmation-email-with-answers branch from cd7fe6f to 338e459 Compare May 27, 2026 16:14
@github-actions
Copy link
Copy Markdown
Contributor

🎉 A review copy of this PR has been deployed! You can reach it at: https://pr-2124.submit.review.forms.service.gov.uk/

It may take 5 minutes or so for the application to be fully deployed and working. If it still isn't ready
after 5 minutes, there may be something wrong with the ECS task. You will need to go to the integration AWS account
to debug, or otherwise ask an infrastructure person.

For the sign in details and more information, see the review apps wiki page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants