diff --git a/services/web/app/src/Features/Email/EmailSender.mjs b/services/web/app/src/Features/Email/EmailSender.mjs index 82dbbc157d..5eaef54202 100644 --- a/services/web/app/src/Features/Email/EmailSender.mjs +++ b/services/web/app/src/Features/Email/EmailSender.mjs @@ -97,7 +97,7 @@ async function sendEmail(options, emailType) { metrics.inc('email') const sendMailOptions = { to: options.to, - from: EMAIL_SETTINGS.fromAddress || '', + from: options.from || EMAIL_SETTINGS.fromAddress || '', subject: options.subject, html: options.html, text: options.text, diff --git a/services/web/test/unit/src/Email/EmailSender.test.mjs b/services/web/test/unit/src/Email/EmailSender.test.mjs index 6b0c75004f..2bf0861f43 100644 --- a/services/web/test/unit/src/Email/EmailSender.test.mjs +++ b/services/web/test/unit/src/Email/EmailSender.test.mjs @@ -99,6 +99,14 @@ describe('EmailSender', function () { }) }) + it('should use opts.from as override for settings fromAddress when provided', async function (ctx) { + ctx.opts.from = 'no-reply@example.com' + await ctx.EmailSender.promises.sendEmail(ctx.opts) + expect(ctx.sesClient.sendMail).to.have.been.calledWithMatch({ + from: 'no-reply@example.com', + }) + }) + it('should not send an email when the rate limiter says no', async function (ctx) { ctx.opts.sendingUser_id = '12321312321' ctx.rateLimiter.consume.rejects({ remainingPoints: 0 })