diff --git a/src/app/config/config.ts b/src/app/config/config.ts index 7384b34456..e6f09c13bf 100644 --- a/src/app/config/config.ts +++ b/src/app/config/config.ts @@ -183,6 +183,7 @@ const mailConfig: MailConfig = (function () { official, mailer, transporter, + sesConfigSet: prodOnlyVars.sesConfigSet, } })() diff --git a/src/app/config/schema.ts b/src/app/config/schema.ts index 7c1b784a06..78e124ecf1 100644 --- a/src/app/config/schema.ts +++ b/src/app/config/schema.ts @@ -452,6 +452,13 @@ export const prodOnlyVarsSchema: Schema = { env: 'SES_PASS', sensitive: true, }, + sesConfigSet: { + doc: 'Config set for SES when sending email', + format: String, + default: null, + env: 'SES_CONFIG_SET', + sensitive: true, + }, dbHost: { doc: 'Database URI', format: (val) => { diff --git a/src/app/services/mail/mail.service.ts b/src/app/services/mail/mail.service.ts index b2b0f8b31d..3b2a4aeff8 100644 --- a/src/app/services/mail/mail.service.ts +++ b/src/app/services/mail/mail.service.ts @@ -247,10 +247,21 @@ export class MailService { } return ResultAsync.fromPromise( - this.#sendMailWithRetries(mail, { - mailId: sendOptions?.mailId, - formId: sendOptions?.formId, - }), + this.#sendMailWithRetries( + { + ...mail, + headers: config.mail.sesConfigSet + ? { + 'X-SES-CONFIGURATION-SET': config.mail.sesConfigSet, + ...mail.headers, + } + : mail.headers, + }, + { + mailId: sendOptions?.mailId, + formId: sendOptions?.formId, + }, + ), (error) => { logger.error({ message: 'Error returned from sendMail retries', diff --git a/src/types/config.ts b/src/types/config.ts index d8a24929ff..13f2bd06d2 100644 --- a/src/types/config.ts +++ b/src/types/config.ts @@ -54,6 +54,7 @@ export type MailConfig = { } official: string transporter: Mail + sesConfigSet: string } export type RateLimitConfig = { @@ -121,6 +122,7 @@ export interface IProdOnlyVarsSchema { user: string pass: string dbHost: string + sesConfigSet: string } export interface ICompulsoryVarsSchema {