( input: ISendTemplateInput )
| 20 | * the address is clean. |
| 21 | */ |
| 22 | export const sendTemplateNow = async ( |
| 23 | input: ISendTemplateInput |
| 24 | ): Promise<ISendOutcome> => { |
| 25 | const suppression = await emailSuppressionService.isSuppressed(input.to); |
| 26 | |
| 27 | if (suppression !== null) { |
| 28 | logger.info("Skipping email send — recipient is on suppression list", { |
| 29 | event: "email_dispatch.suppressed", |
| 30 | to: maskEmailForLogging(input.to), |
| 31 | templatePath: input.templatePath, |
| 32 | reason: suppression.reason, |
| 33 | provider: suppression.provider, |
| 34 | }); |
| 35 | |
| 36 | return { status: "suppressed", reason: suppression.reason }; |
| 37 | } |
| 38 | |
| 39 | const html = emailTemplateService.render(input.templatePath, { |
| 40 | ...baseTemplateVariables(), |
| 41 | subject: input.subject, |
| 42 | ...input.variables, |
| 43 | }); |
| 44 | |
| 45 | await emailService.send({ |
| 46 | to: input.to, |
| 47 | subject: input.subject, |
| 48 | html, |
| 49 | }); |
| 50 | |
| 51 | return { status: "sent" }; |
| 52 | }; |
| 53 | |
| 54 | /** |
| 55 | * Dispatch an email through the configured pipeline: |
no test coverage detected