Repository navigation
feat: Brevo and Amazon SES accounts, language versions and provider opens/clicks for provider templates - #28
Merged
Merged
Conversation
Schero94
force-pushed
the
feat/providers-brevo-ses
branch
from
November 18, 2026 23:06
adfd98c to
2473c47
Compare
Schero94
force-pushed
the
feat/provider-templates
branch
from
November 18, 2026 23:08
882a86a to
936a874
Compare
…open/click tracking Re-landed on main after #20 was squash-merged: the changes of #28 (diff from its #20 base 882a86a) applied onto origin/main, CHANGELOG [Unreleased] merged with #20's entries, StrictMode admin tests added for the Brevo/SES credentials steps and connection check, the Brevo template dialog with language versions and the provider-tracking switch. - Brevo: send, Check connection, webhook token (reveal/rotate, audited), templates with params; Amazon SES v2: own SigV4 (38 official vectors), send, templates, Check connection, SNS-verified events. - Language versions of provider templates (exact -> language -> default). - Provider open/click events counted for provider-template mails. - Brevo and Amazon SES are labelled Beta in the wizard until a live run against their APIs passes (see CHANGELOG Verification). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Schero94
force-pushed
the
feat/providers-brevo-ses
branch
from
November 18, 2026 23:17
dc4669e to
d51f09f
Compare
…open/click tracking Re-landed on main after #20 was squash-merged: the changes of #28 (diff from its #20 base 882a86a) applied onto origin/main, CHANGELOG [Unreleased] merged with #20's entries, StrictMode admin tests added for the Brevo/SES credentials steps and connection check, the Brevo template dialog with language versions and the provider-tracking switch. - Brevo: send, Check connection, webhook token (reveal/rotate, audited), templates with params; Amazon SES v2: own SigV4 (38 official vectors), send, templates, Check connection, SNS-verified events. - Language versions of provider templates (exact -> language -> default). - Provider open/click events counted for provider-template mails. - Brevo and Amazon SES are labelled Beta in the wizard until a live run against their APIs passes (see CHANGELOG Verification). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he tree is the re-land on 4.8.0 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… (React 19 key warning) Found by the informational React 19 StrictMode job. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Schero94
marked this pull request as ready for review
November 19, 2026 12:03
github-actions Bot
pushed a commit
that referenced
this pull request
Nov 19, 2026
# [4.9.0](v4.8.0...v4.9.0) (2026-11-19) ### Features * Brevo and Amazon SES accounts, template languages and provider open/click tracking ([#28](#28)) ([b2c8253](b2c8253)) ### Added * **Brevo accounts.** Send through the Brevo transactional API (`api-key` header) with sender, cc/bcc, reply-to, attachments, filtered headers and the `magicmail_id` correlation header. **Check connection** reads the Brevo account without sending and names the cause of a failure (invalid key, IP not authorised, account under validation, no credits). Brevo templates sync like SendGrid and Mailgun templates and are sent with `templateId` and your `data` as `params` (a Brevo template writes `{{ params.name }}`, you pass `name`). Delivery webhooks are authenticated with a random webhook token MagicMail creates per account (**Show webhook token**, **Replace token**). * **Amazon SES accounts.** Send through the SES v2 API in any commercial or GovCloud region, signed with AWS Signature Version 4 (own implementation, tested against the official AWS SigV4 test suite; no AWS SDK). Credentials are an IAM access key or the server's environment variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN`). **Check connection** shows sandbox and sending status. SES templates sync and are sent with `TemplateData`. Bounces, complaints, deliveries, delays, rejects and opens/clicks arrive through an SES configuration set → SNS → HTTPS subscription; every SNS message is checked against the configured topic ARN and the SNS signature, and the subscription is confirmed automatically. * **Language versions for provider templates.** A provider template can map languages (`de`, `fr`, `pt-BR`, …) to other synced templates of the same provider. `send({ providerTemplate, locale })` picks the exact language, then the base language, then the default; without `locale` the recipient's stored locale is used when the users-permissions user type has a `locale` attribute. Core emails use the user's locale and send it as `meta.locale`; test sends use the admin's interface language or `language`. Unusable versions are skipped. * **Opens and clicks of provider-rendered mails.** New setting **Count provider opens and clicks** (off by default; shown only with a SendGrid, Mailgun, Brevo or SES account). Provider-template sends then ask the provider to track, and the provider's open and click webhook events (SendGrid, Mailgun, Brevo, SES) are counted in Email Analytics, only for those mails, so nothing is counted twice. Clicked links are stored as origin and path only. * **admin API:** `POST /magic-mail/accounts/:accountId/check` (`test-send`, read-only), `POST /magic-mail/accounts/:accountId/webhook-token` (`manage`, browser sessions only, audit-logged), `locales` in `PUT /magic-mail/provider-templates/:key/settings`, `language` in `POST /magic-mail/provider-templates/:key/test-send`. Content API: `POST /api/magic-mail/webhooks/brevo/:accountId`, `POST /api/magic-mail/webhooks/ses/:accountId`. ### Security * Brevo webhooks have no provider signature; MagicMail requires a 256-bit random token per account (constant-time comparison, encrypted at rest, revealed only to browser sessions with `manage`, every reveal logged without the token). SNS messages for SES are verified (topic ARN, certificate host `sns.<region>.amazonaws.com` of the topic's region, no redirects, size-capped certificate fetch, SignatureVersion 1 and 2) before anything is processed. AWS credentials are never read from instance-metadata or ECS endpoints. Provider error bodies are never logged or returned; Brevo and SES connection checks return no personal data. ### Migration * Brevo, Amazon SES, language versions and provider tracking: nothing to do. The email log gets an optional `providerTracking` flag and the settings an optional `providerTracking` switch (off). SendGrid, Mailgun and SMTP requests are unchanged (golden payload tests). `PUT /provider-templates/:key/settings` now accepts `locales`, and `fallbackTemplateReferenceId` is optional there (at least one of the two is required). ### Verification * **Brevo and Amazon SES are marked Beta in the account wizard.** Both are verified against their official API descriptions (Brevo OpenAPI files, the Amazon SES v2 Smithy model), by contract tests on every request and response, by the 38 official AWS SigV4 test vectors and by integration tests against fake servers built from those descriptions, plus a browser acceptance run on Strapi 5.62.0 (SQLite and PostgreSQL). **They have not yet been tested against the live Brevo and Amazon SES APIs.** Only a live run (`npm run test:live` with the `BREVO_*` and `SES_*` variables) can confirm: 1. which header Brevo sends for bearer-token webhook authentication (`Authorization: Bearer <token>` is assumed; the custom header `X-Magic-Mail-Webhook-Token` also works); 2. the wording of Brevo's error messages that select the specific hints (IP not authorised, sender not verified, unknown template); other errors fall back to the hint for their status code; 3. that Amazon SES accepts the per-message `ConfigurationOverrides.Tracking` field used for provider open and click tracking; 4. that SES answers `404 NotFoundException` for an unknown template on `SendEmail`; 5. the verification of a real SNS signing certificate (the tests use self-signed certificates; trust rests on HTTPS to the fixed `sns.<region>.amazonaws.com` host).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft, waiting for the live run (
npm run test:livewith Brevo and Amazon SES credentials in~/.config/magic-mail-live/.env), like #20 and #23. Stacked on #20 (feat/provider-templates), which is stacked on #23; this PR retargets automatically when #20 is merged. Do not merge before a passing live run is recorded indocs/acceptance/2026-11-18-brevo-ses.md.What this adds
1. Brevo account type (
server/src/providers/brevo.js)POST /v3/smtp/email(api-keyheader): sender, to/cc/bcc (deduplicated), one reply-to (several are refused with 400), html/text, attachments (nocid, Brevo's extension list), filtered headers. Correlation:X-Mailin-custom: magicmail_id=<log id>. CallerX-Sib-*/X-Mailin-*headers are dropped. Size limit 20 MB.GET /v3/account, no email sent, no personal data returned) and actionable hints (BREVO_INVALID_KEY,BREVO_IP_NOT_AUTHORIZED,BREVO_ACCOUNT_UNDER_VALIDATION,BREVO_SENDER_NOT_VERIFIED,BREVO_NO_CREDITS, …).POST /magic-mail/accounts/:id/webhook-token(manage, browser sessions only, admin API tokens get 403, audit-logged, rate limited) shows or rotates it. Accepted asAuthorization: BearerorX-Magic-Mail-Webhook-Token, compared in constant time.templateId+params(yourdata; a Brevo template writes{{ params.name }}, the UI says so and lists variables withoutparams.).2. Amazon SES v2 (
server/src/providers/ses.js,utils/aws-sigv4.js,utils/sns-verify.js)@aws-sdk/client-sesv2would add 24 packages / ~16 MB and an instance-metadata credential chain). Own SigV4 (~200 lines, node:crypto), tested against all 38 cases of the official AWS SigV4 test suite.Content.Simple(headers ≤ 15, attachments, RFC 2047 for non-ASCII) orContent.Template(TemplateData),EmailTags(magicmail_id), configuration set,ConfigurationOverrides.Tracking; limits 50 recipients, 40 MB, 256 KiB template data.AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY/AWS_SESSION_TOKEN; no IMDS/ECS fetch), configuration set, SNS topic ARN; Check connection (GetAccount: sandbox, sending, quota).https://sns.<topic-region>.amazonaws.com/SimpleNotificationService-*.pem(no redirects, 16 KB cap, cached), SignatureVersion 1/2 verified, SubscriptionConfirmation confirmed only on the same host pattern, replays ignored.3. Language versions (per-locale provider-template mapping)
PUT /provider-templates/:key/settings { locales: { de: 'brevo:welcome-de' } }; the dialog adds a version in 4 interactions (type language, pick synced template, saved on pick). Same provider only, no chains, no typed ids.send({ providerTemplate, locale }): exact tag → language → default; withoutlocale, the recipient user's stored locale (only when the users-permissions user type has alocaleattribute). Unusable versions are skipped. Core mails use the user's locale and send it asmeta.locale; test sends uselanguageor the admin's interface language. The log records key, sent version and locale.4. Opens and clicks for provider-rendered bodies
tracking_settings, Mailguno:tracking-opens=yes/o:tracking-clicks=htmlonly, SES tracking override; Brevo is account-level) and flag the logproviderTracking.open/click, Mailgunopened/clicked, Brevoopened/clickand SESOpen/Clickevents increase the counters only for those logs (no double counting with MagicMail's pixel), de-duplicated by event id; clicked URLs stored as origin + path only, sensitive links dropped, no provider IP/UA stored.Scaffold:
server/src/providers/index.jsdefines the adapter interface; SendGrid, Mailgun, SMTP and OAuth paths are untouched.Old features
Golden payload tests for SendGrid, Mailgun and SMTP pass unchanged (byte-identical requests). Inventory tests updated for the new routes (
/accounts/:id/check,/accounts/:id/webhook-token,/webhooks/brevo/:id,/webhooks/ses/:id).PUT /provider-templates/:key/settings:fallbackTemplateReferenceIdis now optional (one of it orlocalesrequired) — additive. Minor release.Tests and gates (Node 22.23.1, final commit)
npm test(after rebasing onto feat: provider templates for SendGrid and Mailgun #20 at882a86a): 915 tests, 912 pass, 0 fail, 3 skipped (PostgreSQL multi-process, as before). New suites: brevo-adapter 26, brevo-contract 11, brevo-integration 19, aws-sigv4 41, ses-adapter 22, ses-contract 6, ses-integration 12, sns-verify 13, provider-locales-tracking 20, admin-brevo-ses-ui 6, live-env-providers 2 (LIVE_PROVIDERSnow also acceptsbrevo,ses; the SendGrid/Mailgun suites skip instead of failing when only those are selected).lint,format:check,build,verify,verify:runtime: clean.npm audit --omit=dev: 0. No new dependency.email-api.json(sha256d56adf66…) andaccounts-and-settings.json(e9f90329…) from developers.brevo.com; SES v2 Smithy model fromaws/api-models-aws@9f371492(f34aeda9…); SigV4 vectors fromawslabs/aws-c-auth@cf69fb7e.Browser acceptance
Isolated Strapi 5.62.0 host (127.0.0.1:1398, packed tarball, installed dist identical to the final build, egress blocked, provider hosts redirected to spec-validating fake servers: 0 contract violations, all SigV4 signatures valid), SQLite and PostgreSQL 16:
localefield was stripped byvalidate()(renamed tolanguage, regression test added).Live suite (pending)
Add to
~/.config/magic-mail-live/.env:BREVO_API_KEY,BREVO_FROM,BREVO_TO, optionalBREVO_TEMPLATE_ID;SES_REGION,SES_ACCESS_KEY_ID,SES_SECRET_ACCESS_KEY,SES_FROM, optionalSES_CONFIGURATION_SET,SES_TEMPLATE_NAME. Brevo runs withX-Sib-Sandbox: drop; SES sends only to the mailbox simulator. Today all 15 tests skip with the missing names. Unverified until then: Brevo's bearer header and error texts, SESConfigurationOverridesacceptance, a real SNS certificate.Docs read (2026-11-18): developers.brevo.com (send-transac-email, smtp templates, get-account, create-webhook, secured-webhooks, transactional-webhooks, sandbox mode, api limits, limit headers, ip security) and their OpenAPI files; AWS SES v2 API (SendEmail, GetAccount, ListEmailTemplates, GetEmailTemplate, CommonErrors), SES developer guide (quotas, event publishing, SNS event contents, mailbox simulator), SNS signature verification and HTTP/S subscription docs, IAM "Create a signed AWS API request"; MDN
Intl.getCanonicalLocales; installed Strapi Design System 2.2.4 sources.🤖 Generated with Claude Code