feat: extract email sending into dedicated email-api service with HTML templates #22

Closed
opened 2026-05-27 13:12:15 +00:00 by claude · 0 comments
Member

What

Create a new internal email-api service that centralises all SMTP email sending. api and cv-search-job stop using MailKit directly and call email-api via Refit. All email body templates are upgraded from plain text to styled HTML.

Why

Email sending is duplicated: api has a structured SmtpEmailSender while cv-search-job reads SMTP config directly from IConfiguration with no settings class. Any new service that needs to send email would add a third copy. A dedicated email-api gives one SMTP configuration point, one place to change providers, and opens the door to retries/queueing later.

Scope

  • New Apis/email-api/ — internal Web API (no exposed port; Docker-network-only at http://email-api:8080)
  • New Apis/email-api-models/SendEmailRequest DTO + IEmailApiClient Refit interface + EmailApiSettings
  • api: replace SmtpEmailSender with EmailApiEmailSender (Refit-backed); remove MailKit; delete SmtpSettings from api-models
  • cv-search-job: replace direct MailKit in CvSearchEmailSender with Refit call
  • New EF migration UpdateEmailTemplatesToHtml in myai-data — upgrade body templates to styled HTML (inline CSS, branded header)
  • Docker Compose: new email-api service with Smtp__* vars; remove those vars from api + cv-search-job; add EmailApi__BaseUrl + EmailApi__InternalApiKey to callers

Not in scope

  • Template rendering logic (stays in callers)
  • Retry / queuing
  • Schema changes

Success criteria

  1. dotnet build myAi.sln — zero errors
  2. MailKit referenced only by email-api.csproj
  3. Smtp__* env vars only in email-api service block
  4. All five email types (contact, subscribe, file-download, CV match, job search results) arrive as HTML

Time tracking

Started: 2026-05-27 16:12 UTC

## What Create a new internal `email-api` service that centralises all SMTP email sending. `api` and `cv-search-job` stop using MailKit directly and call `email-api` via Refit. All email body templates are upgraded from plain text to styled HTML. ## Why Email sending is duplicated: `api` has a structured `SmtpEmailSender` while `cv-search-job` reads SMTP config directly from `IConfiguration` with no settings class. Any new service that needs to send email would add a third copy. A dedicated `email-api` gives one SMTP configuration point, one place to change providers, and opens the door to retries/queueing later. ## Scope - New `Apis/email-api/` — internal Web API (no exposed port; Docker-network-only at `http://email-api:8080`) - New `Apis/email-api-models/` — `SendEmailRequest` DTO + `IEmailApiClient` Refit interface + `EmailApiSettings` - `api`: replace `SmtpEmailSender` with `EmailApiEmailSender` (Refit-backed); remove MailKit; delete `SmtpSettings` from `api-models` - `cv-search-job`: replace direct MailKit in `CvSearchEmailSender` with Refit call - New EF migration `UpdateEmailTemplatesToHtml` in `myai-data` — upgrade body templates to styled HTML (inline CSS, branded header) - Docker Compose: new `email-api` service with `Smtp__*` vars; remove those vars from `api` + `cv-search-job`; add `EmailApi__BaseUrl` + `EmailApi__InternalApiKey` to callers ## Not in scope - Template rendering logic (stays in callers) - Retry / queuing - Schema changes ## Success criteria 1. `dotnet build myAi.sln` — zero errors 2. `MailKit` referenced only by `email-api.csproj` 3. `Smtp__*` env vars only in `email-api` service block 4. All five email types (contact, subscribe, file-download, CV match, job search results) arrive as HTML ## Time tracking Started: 2026-05-27 16:12 UTC
gelu closed this issue 2026-05-27 13:34:04 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: AI/myAi#22