Repository navigation
feat: provider templates for SendGrid and Mailgun - #20
Merged
Merged
Conversation
Schero94
force-pushed
the
feat/provider-templates
branch
from
November 18, 2026 14:31
a683ab6 to
1c2f87b
Compare
Schero94
force-pushed
the
feat/provider-templates
branch
2 times, most recently
from
November 18, 2026 21:53
c3ac91e to
2363e3e
Compare
Schero94
force-pushed
the
feat/provider-templates
branch
from
November 18, 2026 22:19
2363e3e to
882a86a
Compare
Schero94
added a commit
that referenced
this pull request
Nov 18, 2026
…ceptance after the rebase onto #20 The SendGrid/Mailgun live suites accept brevo and ses in LIVE_PROVIDERS and skip instead of failing; the Brevo and SES suites honour the selection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Re-applies #20's own changes (0f3b79f..882a86a) on top of 4.7.0, which already contains #23. Conflicts resolved in favour of main: the 4.6.3 dialog labelling, the 4.7.0 send paths with the Mail Send hint and the Strapi 5.63 dev dependencies. The CHANGELOG [Unreleased] section holds only the provider-template entries plus a Verification section. Adds the provider-template screens to the StrictMode admin tests: the templates page loads the overview once, the preview and core-email design dialogs open and close cleanly, and a stale list starts exactly one background sync under StrictMode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Schero94
force-pushed
the
feat/provider-templates
branch
from
November 18, 2026 23:08
882a86a to
936a874
Compare
Schero94
marked this pull request as ready for review
November 18, 2026 23:08
github-actions Bot
pushed a commit
that referenced
this pull request
Nov 18, 2026
# [4.8.0](v4.7.0...v4.8.0) (2026-11-18) ### Features * provider templates for SendGrid and Mailgun ([#20](#20)) ([184115d](184115d)) ### Added * **provider templates:** SendGrid dynamic templates and Mailgun templates (domain and account level) appear read-only under **Email Templates → Provider templates** as soon as a SendGrid or Mailgun account exists. Sync reads them with the stored account key (never writes to the provider), follows the providers' pagination, uses the EU hosts for EU accounts, and refreshes itself when the list is older than 10 minutes. A template whose remote id disappears but whose name still exists on the account (a database moved to another environment) is matched by name. * **provider templates:** preview dialog with a sandboxed preview, the detected variables, a code example, a test send (to your own admin address by default, with the same sample values as local templates), an optional local fallback template, and **Copy as Magic Mail template** (HTML copy; Handlebars blocks become Mustache sections and anything that does not carry over is listed). * **sending:** `send({ to, providerTemplate: '<provider>:<slug>', data })` sends a synced template. The same `data` object that local templates render with Mustache is sent as SendGrid `dynamic_template_data` or Mailgun `t:variables`, converted to plain JSON (dates as ISO strings, no functions, no cycles) and checked against the provider limits (Mailgun: 16 KB for all send options; Magic Mail bounds template data to 1 MB). Routing, rules, failover, quotas and logs work as before, but only between accounts that have the template. Strict by default: a missing template or a provider refusal is a clear error; a local fallback template is sent only when it is configured and no provider accepted the message. The log stores the template key and variable names, never the values. * **core emails:** password reset and email confirmation can use a provider template (**Core emails → Design**). Magic Mail sends the familiar users-permissions names (`URL`, `TOKEN`/`CODE`, `USER`, `SERVER_URL`, `ADMIN_URL`) plus `url` (the finished link), `baseUrl`, `serverUrl`, `adminUrl`, `user`, `token`/`code` and `meta` (`templateKey`, `payloadVersion: 1`, `coreEmailType`). `USER` contains only `id`, `email`, `username`, `firstname`, `lastname`. Optional fallback to the Magic Mail designer version. A red notice on the Core emails tab and the dashboard names core emails whose template is not available. * **templates:** **Convert for SendGrid or Mailgun** in the code snippets dialog turns a local template's Mustache logic into Handlebars for upload at the provider. * **admin API:** `GET /magic-mail/provider-templates`, `POST /magic-mail/provider-templates/sync`, `GET /magic-mail/provider-templates/:key`, `POST /magic-mail/provider-templates/:key/test-send`, `PUT /magic-mail/provider-templates/:key/settings`, `POST /magic-mail/provider-templates/:key/copy`, `GET /magic-mail/designer/templates/:id/provider-html`, `GET /magic-mail/designer/core-designs`, `PUT /magic-mail/designer/core/:coreEmailType/design`. Existing permissions: `read` (sync is read-only at the provider and rate limited), `test-send`, `manage`; the core-email routes also need the users-permissions email-template permissions. ### Security * Provider ids are never accepted from callers, only synced keys. The public Content API send routes do not accept `providerTemplate`. * Template previews render in a sandboxed iframe without scripts. Provider requests go only to the fixed SendGrid and Mailgun hosts, with timeouts and response size limits; paging URLs from the provider are never requested directly. ### Migration * Provider templates: nothing to do. A new collection `magic_mail_provider_templates` is created on start; nothing changes for accounts without SendGrid or Mailgun. Sends without a provider template are byte-identical to 4.7.0 (golden payload tests). Provider-template sends are not queued in the outbox in this release. * To sync SendGrid templates, the SendGrid key also needs **Template Engine → Read Access** (sending alone needs only **Mail Send**). ### Verification * SendGrid: tested live against the real SendGrid API on 2026-11-18, every send in sandbox mode: template sync with pagination, variable detection and preview, template sends, unknown and malformed template ids, the 1 MB data bound, and the template life cycle with temporary templates (no version, a first and a second active version, deleted and re-created under the same name, deleted for good). Temporary objects were deleted afterwards. The EU host could not be tested live (no EU subuser). * Mailgun: verified against Mailgun's official OpenAPI specification and with tests, but not yet against the live Mailgun API. Please report anything unexpected.
Schero94
added a commit
that referenced
this pull request
Nov 18, 2026
…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
added a commit
that referenced
this pull request
Nov 19, 2026
…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>
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.
Provider templates (SendGrid, Mailgun) — minor release (the minor after #23)
Stacked on #23. This PR targets
fix/provider-send-paths(#23) and reuses its shared send-path helpers. GitHub retargets it tomainwhen #23 is merged, so the two can merge back-to-back.Not mergeable yet: the live suites against the real SendGrid and Mailgun APIs (
npm run test:live) have not run. The maintainer test accounts (~/.config/magic-mail-live/.env) still do not exist (checked 2026-11-18). This PR stays a draft until a passing live run is recorded indocs/acceptance/2026-11-17-provider-templates.md. Merge order: #23 first, then this PR.Implements the P1 plan (Strapi RFC #27752): SendGrid dynamic templates and Mailgun templates are synced read-only and listed next to the local templates. MagicMail can preview them, send tests, and send them with the same
dataobject that local templates render. Routing, failover, quotas and logs stay in MagicMail.What changes for users
sendgrid:welcome-email), the date the template last changed at the provider, the accounts that have it and its status. The list syncs itself when it is older than 10 minutes, or on Sync. Without such an account nothing new is visible.api.eu.sendgrid.com); template sync uses the same region helper, so EU accounts sync through the EU host.Behaviour
send({ to, providerTemplate, data })sends the samedataas SendGriddynamic_template_dataor Mailgunt:variables. The data is converted to plain JSON (ISO dates; no functions, cycles or prototype keys).v:magicmail_*,o:tagand tracking options; a template send above it fails before any request withMAGIC_MAIL_PROVIDER_TEMPLATE_TOO_LARGE(other sends keepMAGIC_MAIL_MESSAGE_TOO_LARGE). The same applies to feat(providers): SendGrid EU region and safer SendGrid/Mailgun send paths #23's SendGrid 30 MB check. Template data is capped at 1 MB. Headers are never dropped or shortened.USER). It then sends payload v1: the familiar names plusurl,baseUrl,user,token/codeandmeta.providerTemplate, and provider-template mails are not queued in the outbox in this release.Old features
Stacked on #23 (rebase of 2026-11-18)
server/src/utils/provider-api.jsre-exportsSENDGRID_REGIONS,resolveSendGridRegionandsendGridApiBaseUrlfrom feat(providers): SendGrid EU region and safer SendGrid/Mailgun send paths #23'sserver/src/utils/sendgrid-region.js; this PR's copy is gone. The duplicatemailgunOptionBytesfrom the auto-merge is removed, and so is this PR'stemplate &&guard around the Mailgun 16 KB check.account-manager.js: feat(providers): SendGrid EU region and safer SendGrid/Mailgun send paths #23'sassertSendGridRegionnext to fix(accounts): Mailgun domain validation, key trimming and actionable test errors #22'snormalizeApiProviderConfig(feat(providers): SendGrid EU region and safer SendGrid/Mailgun send paths #23's version). Account wizard: one SendGrid region field (feat(providers): SendGrid EU region and safer SendGrid/Mailgun send paths #23's; this PR's identical copy removed). Translations: a key-level 3-way merge keeps every key of both sides in all five locales. CHANGELOG[Unreleased]: feat(providers): SendGrid EU region and safer SendGrid/Mailgun send paths #23's entries plus this PR's, one Migration list.mailgun.json,sendgrid-mail.json,openapi-contract.jsandextract-openapi.jswere byte-identical (SHA-256) and exist once; this PR adds onlysendgrid-templates.json.local-sendgrid.jsoncustom_args.magicmail_id;tracking_settings.click_tracking/open_tracking.enable=falseplain-sendgrid.json,core-reset-sendgrid.jsoncustom_args.magicmail_id;tracking_settings.open_tracking.enable=falselocal-sendgrid-untracked.jsoncustom_args.magicmail_idlocal-mailgun.jsono:tracking-opens=no,o:tracking-clicks=no,v:magicmail_email_type,v:magicmail_priority,v:magicmail_id,o:tagcore-reset-mailgun.jsono:tracking-opens=no,v:magicmail_email_type,v:magicmail_priority,v:magicmail_id,o:taglocal-mailgun-untracked.jsonv:magicmail_email_type(marketing),v:magicmail_priority(high),v:magicmail_id,o:tag(marketing)local-smtp.json,core-reset-smtp.jsonThe fake delivery logs in the golden and provider-template harnesses now return alphanumeric documentIds like Strapi (
golddoc1,logdoc1instead oflog-1). #23 sends only ids matching/^[A-Za-z0-9]{1,64}$/, so the old fake id silently suppressedmagicmail_id.custom_args.magicmail_id/v:magicmail_*/o:tagand no provider tracking switches; template data that fits 16 KB alone but not with the metadata is refused before any request, exactly 16 KB is accepted.npm run test:live=node --test --test-concurrency=1 tests/live/*.live.test.jsrunstests/live/provider-send.live.test.js(feat(providers): SendGrid EU region and safer SendGrid/Mailgun send paths #23) andtests/live/provider-templates.live.test.js. Credentials only from~/.config/magic-mail-live/.env, never printed. Required:SENDGRID_API_KEY,SENDGRID_FROM,SENDGRID_TEMPLATE_ID,MAILGUN_API_KEY,MAILGUN_DOMAIN,MAILGUN_REGION,MAILGUN_TEMPLATE,LIVE_TEST_RECIPIENT; optionalSENDGRID_REGION,SENDGRID_EU_API_KEY,SENDGRID_EU_FROM,MAILGUN_FROM,MAILGUN_EU_DOMAIN,MAILGUN_EU_API_KEY. Without the file: the send suite skips all 15 tests with the path, the template suite fails test 1 with the path (10 skipped), exit 1.aria-describedby={undefined}like the other plugin dialogs; checked against the installed@radix-ui/react-dialog1.1.5 source).fb24a7f(Node 22.23.1): lint, format check,npm test(693 tests, 690 pass, 3 skipped PostgreSQL),test:multi-instance(49/46, 3 skipped PostgreSQL), build, verify, verify:runtime,npm ci --ignore-scriptswith npm 10.9.8 and 11.21.2.eu; Mailgun domainmg.example.test/v3shows the inline error,https://MG.example.test/is saved asmg.example.test; sync (EU account viaapi.eu.sendgrid.com), preview, test sends through SendGrid US/EU and Mailgun with feat(providers): SendGrid EU region and safer SendGrid/Mailgun send paths #23's metadata, copy, fallback, core-email design. 1440 and 390, light and dark: document overflow 0, nothing outside the viewport, 0 plugin console messages. Host stopped and secrets deleted.Evidence
twilio/sendgrid-oaiat51a0deedocs/acceptance/2026-11-17-provider-templates.md.Docs read (docs-first, checked 2026-11-17)
template,t:variables,t:text,o:testmode, "Send options ... limited to 16KB total")controllers/auth.jsandservices/user.js(installed)Release
[Unreleased]section has migration notes; no action is needed by users.npm run test:live.🤖 Generated with Claude Code