By Schero
Professional-grade multi-account email management with smart routing, OAuth 2.0 support, and complete security compliance — 100% free and open source
released November 26, 2026
npm install strapi-plugin-magic-mail
Send every Strapi email through the right account: several SMTP and API accounts, routing rules, quotas, failover that never doubles a mail, an outbox with retries, templates and delivery tracking, all inside the Strapi admin.
Live docs: https://schero94.github.io/Magic-Mail/
Your code keeps calling strapi.plugin('email').service('email').send(). Strapi's password-reset mail and every Users & Permissions mail go through MagicMail without changes. MagicMail picks the account, reserves its quota, logs the mail and tells you what happened to it.
MagicMail sends email only. It is MIT licensed, with no license key, tiers or usage limits.
de, fr, pt-BR … to translated templates; MagicMail picks the version from locale or the user's stored locale, falling back to the language and then the default (details).api.eu.sendgrid.com (setup).https:// or trailing slash is removed for you; a value that is not a domain name is flagged right in the form instead of failing later when mail is sent.webhooks.maxBodyBytes).All screenshots show synthetic data (example.test addresses) on an isolated Strapi 5.62.0 host, captured at 1080 px wide and 2x pixel density so the text stays readable in a narrow column.
Email accounts: status, provider, priority, today's usage against the daily limit, total sent and last use, with edit, test and delete per account.

Routing rules: rules in evaluation order with match type and value, target and fallback account, and priority.

Outbox: mails waiting for a retry, failed for good, or uncertain, with attempts and the next try or last error code. Retry, mark as sent and discard per row.

Templates: Reference ID, category and status; edit in the visual or HTML editor, download, duplicate, code snippets, test send.

Provider templates: with a SendGrid or Mailgun account, their templates appear under your own, with the provider, the change date there, the accounts that have them and their status.

Brevo and Amazon SES accounts: the wizard asks only for what the provider needs, checks the connection without sending and shows the webhook URL and setup steps (Amazon SES and language versions have their screenshots in the sending guide).

Analytics: totals and the delivery log with server-side search, delivery status, opens and clicks per email.

Dark mode: every screen follows the Strapi admin theme.

More screens (account wizard, outbox details, template editor, settings, mobile) are in the gallery on the docs site.
About a minute in an existing Strapi 5 project:
npm install strapi-plugin-magic-mail
# yarn add strapi-plugin-magic-mail | pnpm add strapi-plugin-magic-mail// config/plugins.js (config/plugins.ts: export default () => ({ ... }))
module.exports = () => ({
'magic-mail': { enabled: true },
});# Outside development and test MagicMail needs an encryption key. Generate it once and keep it.
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
# .env
MAGIC_MAIL_ENCRYPTION_KEY=<the generated value>npm run build
npm run developOpen MagicMail → Email Accounts, click Add account, pick a provider (see Provider setup) and use the account's Test action with your own address. From now on every strapi.plugin('email') call goes through MagicMail.
Keep the encryption key stable: without it the stored account credentials cannot be read. Super admins see MagicMail right away; other roles need the permissions access and read.
| MagicMail | Strapi | Node.js | Databases |
|---|---|---|---|
| 4.x | ^5.57.0 (acceptance host: Strapi 5.63.0) | >=22.12.0 <=26.x.x (CI runs Node 22, 24 and 26) | PostgreSQL, MySQL 8, SQLite. Several processes: PostgreSQL tested, MySQL not load-tested |
| 3.1 | ^5.57.0 | >=20.19.0 <=26.x.x | as Strapi |
@strapi/strapi, @strapi/plugin-users-permissions (every default Strapi app has it; the email log links to its users), react, react-dom, react-router-dom and styled-components as in a create-strapi-app project. @strapi/design-system, @strapi/icons and react-intl are optional peers, which the Strapi admin provides.MagicMail wraps the provider of @strapi/email at startup, so existing code keeps working:
await strapi.plugin('email').service('email').send({
to: 'user@example.com',
subject: 'Welcome to Example Shop',
text: 'Thanks for signing up!',
html: '<h1>Welcome!</h1><p>Thanks for signing up!</p>',
});Both send() and sendTemplatedEmail() are routed, including Strapi's admin password-reset email and the Users & Permissions emails. When no MagicMail account is active, or every eligible account is over its quota, the mail goes through the Strapi email provider you configured before. Once a MagicMail account has attempted delivery, an error is returned instead, so nothing goes out twice.
Need a specific account, a template or the outbox? Use the router service:
await strapi.plugin('magic-mail').service('email-router').send({
to: 'customer@example.com',
subject: 'Order confirmation',
html: '<h1>Your order #12345</h1>',
accountName: 'Transactional SMTP', // case-insensitive; never replaced by another account
type: 'transactional',
});
// → { success: true, accountUsed: 'Transactional SMTP', messageId: '<…>', emailId: '…' }Designed your email in SendGrid, Mailgun, Brevo or Amazon SES? Send the synced template with the same data a MagicMail template gets (only accounts that have the template send it):
await strapi
.plugin('magic-mail')
.service('email-router')
.send({
to: 'customer@example.com',
providerTemplate: 'sendgrid:welcome-email', // key shown in Email Templates → Provider templates
data: { name: 'Ada', user: { email: 'customer@example.com' } },
locale: 'de', // optional: picks the German language version when one is set
});All send options, attachments, unsubscribe headers, provider setup, routing rules, templates and provider templates: Sending guide. HTTP routes: API reference.
MagicMail registers seven admin actions under Settings → Administration Panel → Roles → Plugins → MagicMail:
| Action | Grants |
|---|---|
plugin::magic-mail.access | The MagicMail menu entry and page. No API access by itself |
plugin::magic-mail.read | Read accounts, routing rules, templates, analytics and settings; render and export templates; the settings link |
plugin::magic-mail.manage | Create, update and delete accounts, rules, templates, logs and settings; OAuth setup |
plugin::magic-mail.test-send | Send test emails (account test, Strapi-service test, template and provider-template test) and run the read-only Brevo/SES connection check; 10 per minute per admin |
plugin::magic-mail.queue.read | The Outbox tab and queue statistics (no mail content) |
plugin::magic-mail.queue.manage | Retry, discard, mark as sent and delete outbox mails |
plugin::magic-mail.content.read | View email content: the Preview and Variables tabs of a sent email (needs read too). Not granted automatically, except to Super Admins |
Typical roles:
access + readaccess + read + manageaccess + read + test-sendWhen upgrading to 4.4, every role that already had read gets queue.read and every role with manage gets queue.manage, once at startup. Super admins always have both.
Editing the Users & Permissions templates also needs the users-permissions email-template permissions; uploading images in the visual editor needs Media Library → Create (upload). Details: permission migration guide.
| Variable | Required | Purpose |
|---|---|---|
MAGIC_MAIL_ENCRYPTION_KEY | yes, unless NODE_ENV is unset, development or test | Credential encryption key (32+ bytes). Keep it stable and backed up |
MAGIC_MAIL_ENCRYPTION_KEY_PREVIOUS | no | Previous key during a rotation (decrypt only; saving an account re-encrypts it) |
MAGIC_MAIL_OAUTH_STATE_SECRET | no | OAuth state signing secret (default: derived from the encryption key) |
MAGIC_MAIL_TRACKING_SECRET | no | Tracking hash secret (default: derived from the encryption key) |
MAGIC_MAIL_TRACKING_SECRET_PREVIOUS | no | Comma-separated old tracking secrets that stay valid |
URL | no | Legacy override of the OAuth callback base URL (default: server.url) |
MAGIC_MAIL_ENABLE_DEBUG_ENDPOINT | no | true enables GET /magic-mail/analytics/debug outside production |
Without MAGIC_MAIL_ENCRYPTION_KEY, a development key derived from ADMIN_JWT_SECRET/APP_KEYS is used only when NODE_ENV is unset, development or test; rotating those secrets then makes stored credentials unreadable. Any other environment (for example staging) refuses to start without the key.
Also set Strapi's server.url to your public URL (OAuth redirects, tracking links) and server.proxy.koa: true behind a reverse proxy.
Every plugin config key, the admin settings and the multi-instance setup are in the configuration guide.
MAGIC_MAIL_ENCRYPTION_KEY with HKDF). The admin API returns the placeholder ******** instead of a secret, and changing the host, user, provider or OAuth client, or the IMAP host used for bounce monitoring, requires the secret again.access only shows the menu entry.@strapi/plugin-graphql installed, MagicMail's content types are kept out of the GraphQL schema, so API tokens can not read or change logs, templates or settings through it.contentApi.allowUserRoles), reject unknown fields, file-path and URL attachments, and share 60 requests per minute per token across all instances. Never enable them for the Public role.from is pinned to the sending account's address, custom headers are allowlisted, and SMTP requires TLS 1.2 or newer with certificate checks (unless allowInsecure is set on a non-production or loopback host).manage in a browser session, every reveal is audit-logged); Amazon SES (SNS) messages need the configured topic ARN and a valid SNS signature from an AWS SNS certificate host; replays are ignored and bodies are capped (1 MiB by default). Provider messages are not stored; addresses only as a keyed hash plus a masked form (suppression list) or a masked form (events for cc/bcc recipients). Brevo and Mailgun events only update mail of their own account.{{system.*}} tags, so Analytics can re-render the email. Secrets are masked before storing: keys that name a secret (password, token, secret, otp, jwt, key, code, reset, confirmation, session, auth and similar), values that look like tokens (JWTs, long hex or random strings, UUIDs) and URLs with tokens (?code=, ?confirmation=, ?token=, ?loginToken=, signatures, token path segments), which covers Strapi reset-password, email-confirmation and magic links. Add names to Always hide these variables or Never hide these variables in the settings. Store a copy of sent emails (off by default) also keeps the final HTML and text, masked and compressed (512 KB cap). Everything follows Keep email content for (30 days by default) and never outlives the log. The preview runs in a sandboxed frame without links, removes tracking pixels, and blocks remote images until "Load images". Viewing needs content.read and is audit-logged.forgetRecipient(address) removes a recipient's queued mails.Reporting a vulnerability: use GitHub private vulnerability reporting. Please do not open a public issue for security problems.
| Guide | What it covers |
|---|---|
| Docs site | Overview, screenshot gallery, install, outbox, several instances |
| Sending, providers, routing and templates | Send options, attachments, Gmail/Microsoft 365/Yahoo/SMTP/SendGrid/Mailgun/Brevo/Amazon SES setup, routing rules, quotas, failover, templates, the visual editor and its CSP |
| Tracking, bounces and the outbox | Open and click tracking, retention, bounce webhooks and mailbox monitoring, recipient checks, retries and the outbox |
| Content API and Admin API | Every route with request, response and error examples |
| Configuration and several instances | Every config key, admin settings, account fields, service API, Railway replicas and pm2 clusters |
| Troubleshooting and FAQ | Mail not received, OAuth errors, 400/403/429 responses, CSP, DMARC |
| Live webhook checks | Checking the SendGrid and Mailgun webhooks against your real accounts: test buttons, a real bounce, what to expect |
| Upgrading | Migration notes for every release since 4.0.0 |
| Permission migration | Granting the 4.x admin capabilities |
| Changelog | Every release |
Bug reports, fixes and documentation improvements are welcome.
[magic-mail] log lines (remove addresses and secrets first).Development setup:
npm ci --ignore-scripts
npm run lint
npm run format:check
npm test
npm run test:admin
npm run build
npm run verify
npm run verify:runtimenpm run test:live runs the opt-in live suites against the real SendGrid and Mailgun APIs: the send paths (tests/live/provider-send.live.test.js), the provider-template flows (tests/live/provider-templates.live.test.js) and the rest of the SendGrid integration (tests/live/sendgrid-account.live.test.js: restricted API keys, template versions, read-only account checks; it creates temporary magic-mail-live-* API keys and templates and deletes them again, so its key needs full access). SendGrid runs in sandbox mode and Mailgun in test mode, so nothing is delivered (Mailgun bills test-mode messages). Credentials come only from ~/.config/magic-mail-live/.env and are never printed. LIVE_PROVIDERS (environment variable or a line in that file) picks the providers as a comma-separated list of sendgrid, mailgun, brevo and ses; without it, every provider whose required variables are complete runs. Tests of a provider that is not selected are skipped with the reason. For SendGrid only: LIVE_PROVIDERS=sendgrid npm run test:live. Required per provider: SendGrid needs SENDGRID_API_KEY, SENDGRID_FROM, LIVE_TEST_RECIPIENT and, for the template suite, SENDGRID_TEMPLATE_ID; Mailgun needs MAILGUN_API_KEY, MAILGUN_DOMAIN, MAILGUN_REGION, LIVE_TEST_RECIPIENT and, for the template suite, MAILGUN_TEMPLATE. Optional: SENDGRID_REGION, SENDGRID_EU_API_KEY, SENDGRID_EU_FROM, MAILGUN_FROM, MAILGUN_EU_DOMAIN, MAILGUN_EU_API_KEY. Without the file, or when a selected provider misses a variable, the template suite fails with the file name and the missing variable names (the send suite reports those tests as skipped). Brevo (tests/live/brevo.live.test.js, sandbox header X-Sib-Sandbox: drop, nothing delivered) needs BREVO_API_KEY, BREVO_FROM, BREVO_TO and optionally BREVO_TEMPLATE_ID; Amazon SES (tests/live/ses.live.test.js, only the SES mailbox simulator success@ and bounce@simulator.amazonses.com) needs SES_REGION, SES_ACCESS_KEY_ID, SES_SECRET_ACCESS_KEY, SES_FROM and optionally SES_CONFIGURATION_SET, SES_TEMPLATE_NAME; both skip with the missing names when their variables are not set. It never runs in CI. Never commit that file.
npm run test:admin renders every admin entry point (the five sections of the MagicMail page with their dialogs, the template editor, the Plugin Settings page) inside React.StrictMode with the providers of the Strapi admin, in jsdom with a fake network. It fails on a mutation sent twice, a read repeated without aborting the first one, an interval, listener, connection or observer left after unmount, and any console error or warning. A separate CI job runs the same tests against React 19 for information only: the plugin's peer range is React 18, like the Strapi 5 admin.
npm run test:multi-instance runs the multi-process suite (set MAGIC_MAIL_TEST_PG_URL for PostgreSQL). npm run watch (or npm run watch:link with yalc) rebuilds the admin and the server bundle on change. CI runs the same checks on Node 22 and 24 for every pull request and every push to main. Use Conventional Commits (fix:, feat:, docs:); releases are cut from main by semantic-release.
Dependabot proposes updates weekly, after a cooldown (7 days, 14 for majors). .github/workflows/dependency-auto-merge.yml handles its pull requests with the rules in .github/scripts/dependency-gate.mjs. The script is the same in every Magic plugin repository; its unit tests run with node --test .github/scripts/dependency-gate.test.mjs and in CI.
github-actions): an explicit patch or minor update, after the repository's own checks pass, the gate finds nothing below, and every other check on the PR head commit has finished green: every CI job and matrix entry (for example Node versions, peer floor, React 19 StrictMode) and CodeQL where present. The merge is bound to that exact commit (--match-head-commit).needs-review plus a comment with the reasons, never merged automatically) when:
engines.node no longer covers a Node version this plugin supports, or its peerDependencies no longer match the installed tree or this plugin's peer floor;npm pack file list (content hashes ignored), exports, peerDependencies, engines, or the exports of the built entry files;npm audit signatures reports a missing or invalid registry signature or provenance attestation;registry.npmjs.org;major-update label and a comment; a person reads the changelog and merges by hand.The gate script runs from the default branch and reads lockfiles and reports as data; it never runs code from the pull request. Only the surface job installs (without lifecycle scripts) and builds the pull request, with a read-only token. Merges made with GITHUB_TOKEN do not start release.yml, so a dependency update ships with the next regular release.
Dependency audits. Run npm audit from your Strapi project root to check the complete installed tree; npm applies overrides from the root project only. MagicMail validates every request with its own zod (^4.6.7) and bounds all collections. Strapi itself ships other zod copies inside @strapi/* packages; if npm audit in your project reports one of them, the fix comes with a Strapi update.
Maintenance status. Actively maintained. Releases follow semantic versioning and support the Strapi 5 line.
Languages. The admin UI is available in English, German, French, Spanish and Portuguese.
Using MagicMail in production? Add your company to the "Used by" section of the documentation site. The form asks for the company name, the website, a logo (PNG, JPEG or WebP, uploaded to the issue) and an optional one-line description.
A maintainer reviews every request and approves it with the showcase-approved label. .github/workflows/showcase.yml then validates the issue with .github/scripts/showcase.mjs, converts the logo to a WebP of at most 320 x 160 pixels and opens a docs: pull request that changes docs/site/showcase.json. The logo appears on the site after that pull request is merged. Website links carry rel="ugc noopener". To remove an entry, open an issue that names the company; a maintainer then applies the showcase-remove label.
MIT License, Copyright © 2025 Schero D. See LICENSE.
Built with Strapi, Nodemailer, Unlayer / react-email-editor, Heroicons and styled-components.
Share your work with the community and get it listed in the Strapi ecosystem for everyone to discover and use.
Submit
